Aide-mémoire des commandes Git

Référence rapide des commandes Git courantes, couvrant les bases, les branches, les dépôts distants, l'annulation et plus. 100 % gratuit, exécuté localement dans votre navigateur — rien n'est téléversé vers nos serveurs.

Basic

git initInitialize a new repositoryCliquez pour copier
git clone <url>Clone a remote repositoryCliquez pour copier
git statusShow working tree statusCliquez pour copier
git add <file>Stage file(s) for commitCliquez pour copier
git add .Stage all changesCliquez pour copier
git commit -m "msg"Commit staged changesCliquez pour copier
git diffShow unstaged changesCliquez pour copier
git diff --stagedShow staged changesCliquez pour copier

Branch

git branchList local branchesCliquez pour copier
git branch <name>Create a new branchCliquez pour copier
git checkout <branch>Switch to branchCliquez pour copier
git checkout -b <name>Create & switch to branchCliquez pour copier
git switch <branch>Switch to branch (new)Cliquez pour copier
git switch -c <name>Create & switch (new)Cliquez pour copier
git merge <branch>Merge branch into currentCliquez pour copier
git branch -d <name>Delete a branchCliquez pour copier
git branch -m <old> <new>Rename a branchCliquez pour copier

Remote

git remote -vList remote repositoriesCliquez pour copier
git remote add <name> <url>Add a remoteCliquez pour copier
git fetchFetch from remoteCliquez pour copier
git pullFetch & mergeCliquez pour copier
git pushPush to remoteCliquez pour copier
git push -u origin <branch>Push & set upstreamCliquez pour copier
git remote remove <name>Remove a remoteCliquez pour copier

Undo/Reset

git reset HEAD <file>Unstage a fileCliquez pour copier
git checkout -- <file>Discard working changesCliquez pour copier
git restore <file>Discard working changes (new)Cliquez pour copier
git reset --soft HEAD~1Undo last commit, keep stagedCliquez pour copier
git reset --mixed HEAD~1Undo last commit, keep unstagedCliquez pour copier
git reset --hard HEAD~1Undo last commit, discard allCliquez pour copier
git revert <commit>Create undo commitCliquez pour copier

Stash

git stashStash current changesCliquez pour copier
git stash listList stashesCliquez pour copier
git stash popApply & remove latest stashCliquez pour copier
git stash applyApply latest stashCliquez pour copier
git stash dropRemove latest stashCliquez pour copier
git stash push -m "msg"Stash with a messageCliquez pour copier

Log

git logShow commit historyCliquez pour copier
git log --onelineCompact commit historyCliquez pour copier
git log --graphGraph of branchesCliquez pour copier
git log -n <count>Show last N commitsCliquez pour copier
git show <commit>Show commit detailsCliquez pour copier
git blame <file>Line-by-line historyCliquez pour copier

Tag

git tagList tagsCliquez pour copier
git tag <name>Create lightweight tagCliquez pour copier
git tag -a <name> -m "msg"Create annotated tagCliquez pour copier
git tag -d <name>Delete a tagCliquez pour copier
git push origin --tagsPush tags to remoteCliquez pour copier