Skip to main content

Git every day

Git saves a series of changes to a repository. A useful commit represents a coherent intention that can be understood, tested and eventually cancel.

The basic loop

git status
git diff
git add chemin/du/fichier
git commit -m "Explique le changement"
git push

Before each commit:

  1. consult git status;
  2. read the diff;
  3. only add files related to the same change;
  4. Run project checks.

Working with branches

git switch -c parcours-fondamentaux
git switch main
git pull --ff-only
git merge parcours-fondamentaux

git switch makes the intention to switch branches more explicit than git checkout, which remains used in many older tutorials.

Undo without randomly erasing

  • git restore fichier returns a file to its saved state: check first the diff, because local changes will be lost;
  • git revert <commit> creates a new commit which undoes an old commit;
  • git reset moves local history and asks for more caution;
  • do not rewrite a history already shared without coordination.

Quick challenge

Create a branch, modify two files, then make two separate commits corresponding to two intentions. Then use git log --oneline to explain the story of change to another person.

Move from the reference sheet to the lab

Want to see branches move, type the commands, and learn to repair team incidents without risking a real repository? Git Mastery takes you from your first commit to conflicts, rebase, reflog, bisect, and realistic multi-actor cases.

Discover the Git Mastery path (French course) →