Aller au contenu principal
TOP free online tools Votre établi
Français
Référence Dernière mise à jour: 2026-11-23

Aide-mémoire des commandes et workflows Git

Référence CLI Git filtrable couvrant initialisation, indexation, branches, rebase, stash, inspection d'historique, annulation et dépôts distants.

Cliquez sur une cellule pour copier
38 / 38
CommandActionStageExample
git initInitialize a new empty Git repository in the current directorySetupgit init -b main
git clone <url>Download a remote repository and its commit historySetupgit clone --depth 1 https://github.com/org/repo.git
git status -sbShow concise working tree status and current branchInspectgit status -sb
git add -pInteractively stage individual hunks before committingStaginggit add -p src/
git add -AStage all modified, new, and deleted files in the repoStaginggit add -A
git restore --staged <file>Unstage a file while preserving working directory editsStaginggit restore --staged package.json
git restore <file>Discard unstaged working tree modifications in a fileUndogit restore src/index.ts
git commit -m "<msg>"Record staged snapshot into repository historyCommitgit commit -m "feat: add schema generator"
git commit --amend --no-editFold staged changes into the previous commit without changing its messageCommitgit commit --amend --no-edit
git diffShow unstaged line-by-line differences in working directoryInspectgit diff --stat
git diff --stagedShow changes currently staged for the next commitInspectgit diff --staged
git log --oneline --graph -n 15Display compact commit graph for recent 15 commitsInspectgit log --oneline --graph --decorate -n 15
git show <commit>Inspect metadata and full diff for a specific commit or tagInspectgit show HEAD~1 --stat
git blame -L <start>,<end> <file>Show who last modified each line in a range and in which commitInspectgit blame -L 10,40 src/auth.ts
git grep "<pattern>"Fast search for patterns across tracked repository filesInspectgit grep -n "parseCronExpression"
git switch -c <branch>Create and switch to a new branch safelyBranchinggit switch -c feat/curl-converter
git switch <branch>Switch to an existing local or tracked remote branchBranchinggit switch main
git branch -vvList local branches with upstream tracking status and last commitBranchinggit branch -vv
git branch -d <branch>Delete a branch safely (only if already merged)Branchinggit branch -d feat/old-branch
git merge --no-ff <branch>Merge branch while preserving an explicit merge commitMergegit merge --no-ff feat/api-v2
git merge --squash <branch>Combine all commits from a branch into staged changes for one commitMergegit merge --squash feat/cleanup
git rebase <base>Reapply current branch commits sequentially on top of base branchRebasegit rebase origin/main
git rebase -i HEAD~<n>Interactive rebase to squash, reword, reorder, or drop recent commitsRebasegit rebase -i HEAD~4
git cherry-pick <commit>Apply changes from a specific commit onto the current branchHistorygit cherry-pick a1b2c3d
git stash push -m "<msg>"Temporarily shelve tracked dirty changes with a descriptive labelStashgit stash push -m "wip: header parser"
git stash popReapply the latest stash and remove it from the stash stackStashgit stash pop
git stash listList all saved stash entriesStashgit stash list
git fetch --pruneFetch remote updates and prune deleted remote-tracking branchesRemotegit fetch --prune origin
git pull --rebaseFetch remote commits and rebase local unpushed commits cleanlyRemotegit pull --rebase origin main
git push -u origin <branch>Push local branch and set upstream tracking referenceRemotegit push -u origin feat/schema-guides
git push --force-with-leaseSafely force-push rewritten history only if remote matches expected tipRemotegit push --force-with-lease origin feat/rebase
git reset --soft HEAD~1Undo the last commit while keeping its changes stagedUndogit reset --soft HEAD~1
git reset --hard <ref>Reset HEAD, index, and working directory to target commit (destructive)Undogit reset --hard origin/main
git revert <commit>Create a new inverse commit that safely undoes a published commitUndogit revert e4f5a6b
git reflogView local HEAD movement history to recover lost or reset commitsRecoverygit reflog -n 20
git bisect startBinary search commit history to pinpoint when a bug was introducedDebuggit bisect start HEAD v1.4.0
git worktree add <path> <branch>Check out a second branch simultaneously in a separate directoryWorkspacegit worktree add ../hotfix main
git tag -a <tag> -m "<msg>"Create an annotated release tag with tagger metadata and messageReleasegit tag -a v2.1.0 -m "Release 2.1.0"

Outils associés

Guides associés

Références associées

Questions fréquentes

When should I use git revert instead of git reset?
Use git revert <commit> on shared or pushed branches because it records a new inverse commit without rewriting history. Reserve git reset for local unpushed commits where moving the branch pointer is safe.
What is the difference between git switch/restore and git checkout?
Modern Git separates git checkout into two safer, single-purpose commands: git switch creates or changes branches, while git restore unstages index entries or discards working-tree file modifications.
How can I recover a commit lost after an accidental git reset?
Run git reflog to list recent local HEAD movements, find the commit hash from before the reset, and recover it with git switch -c recovery <hash> or git reset --hard <hash>.