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:
- consult
git status; - read the diff;
- only add files related to the same change;
- 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 fichierreturns 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 resetmoves 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.