MicrolearnENPTES

Learn Git: 24 free interactive lessons

3 to 5 minute lessons with a real Git terminal in your browser: commits, branches, merges and conflicts, remotes, reset, revert and rebase. Every lesson ends with a mission you solve with real commands.

Do it in the browser: a real Git tool, a short mission and instant feedback. No install. Optional certificate at the end of the course.

Open the course

Lessons

  1. Your first repositoryGit keeps the history of a project folder: every saved version, who made it and when. A folder becomes a Git repository with one command,…
  2. The staging areaBefore saving a version, you choose what goes into it. git add copies a file into the staging area (also called the index): the draft of…
  3. Your first commitA commit is a saved snapshot of everything in the staging area, with a message, an author and a date. It is the unit of history in Git.
  4. Reading the historyEach commit remembers its parent, so the commits form a chain: the history. git log walks it from the newest commit back to the first.
  5. What changed? git diffBefore you commit, look at what you changed. git diff compares versions line by line, so you can commit related changes together.
  6. Undo changes in a fileBroke a file and want the last saved version back? git restore replaces your copy with the one Git has saved.
  7. Take a file out of the staging areaStaged something by mistake? You can take it out of the staging area without losing anything: the file stays in your folder exactly as it…
  8. Ignore files with .gitignoreSome files should never be committed: logs, build output, downloaded libraries. List them in a .gitignore file and Git stops offering them.
  9. Branches are pointersA branch lets you work on something new without touching the main line. In Git it is just a label that points at a commit, so creating one…
  10. HEAD and moving through historyHEAD marks where you are. Usually it points at a branch, but you can also point it at any old commit to look at the project as it was.
  11. Merging: fast-forwardWhen a branch is ready, you merge it into main. If main hasn't moved since the branch started, Git just slides main forward: a fast-forward.
  12. Three-way mergesIf both branches got new commits, Git can't just slide one forward. It compares both tips with their common ancestor and creates a merge…
  13. Resolving a merge conflictWhen both branches changed the same lines, Git can't choose for you. It stops the merge, marks the conflict in the file and waits for you…
  14. Pick a side: --ours and --theirsSometimes one side of a conflict is simply right. Instead of editing by hand, take that whole version of the file.
  15. Stash: put work asideHalfway through something and an urgent fix comes in? git stash puts your unfinished changes aside, leaves the folder clean, and gives…
  16. Tags for releasesA tag is a permanent name for a commit, usually a version number such as v1.0. Unlike a branch, it never moves.
  17. Publish your work: pushA remote is another copy of the repository, usually on a server such as GitHub or GitLab. git push sends your commits there so others can…
  18. Get updates: fetch and pullYour teammates push to the same server. To work on top of their changes, bring them into your copy.
  19. When a push is rejectedIf someone pushed while you were working, the server refuses your push: accepting it would erase their commits. Integrate their work first.
  20. Feature branches and pull requestsTeams rarely push straight to main. Each change goes on its own branch, which is pushed and reviewed in a pull request before it is merged.
  21. Fix the last commit: --amendTypo in the message, or a file left out? git commit --amend replaces the last commit with a corrected one.
  22. reset: move a branch backgit reset moves the current branch to another commit. The commits after it leave the branch, and the options decide what happens to your…
  23. revert: undo a published commitOnce a commit is on the server, don't rewrite history. git revert creates a new commit that does the exact opposite of the old one.
  24. Rebase and cherry-pickA merge keeps both lines of history. A rebase instead replays your commits on top of another branch, as if you had started from there: the…