Git Command Cheatsheet
Quickly find a Git command by keyword (branch, commit, rebase, stash...), organized by category, with a button to copy each command straight to your terminal.
Start
git initgit clone <url>git config --global user.name "Nom"git config --global user.email "email"Status & history
git statusgit loggit log --oneline --graph --allgit diffgit diff --stagedgit show <commit>Edit
git add <fichier>git add -Agit commit -m "message"git commit --amendgit restore <fichier>git restore --staged <fichier>git rm <fichier>Branches
git branchgit branch <nom>git switch <branche>git switch -c <branche>git branch -d <branche>git branch -D <branche>Merge & rebase
git merge <branche>git rebase <branche>git rebase -i HEAD~ngit cherry-pick <commit>Remote
git remote -vgit fetchgit pullgit pushgit push -u origin <branche>git push --force-with-leaseCancel
git reset --soft HEAD~1git reset --mixed HEAD~1git reset --hard HEAD~1git revert <commit>Stash
git stashgit stash popgit stash listLabels
git taggit tag -a v1.0.0 -m "message"git push origin --tagsHow it works
Around forty common Git commands are organized by category (getting started, state and history, branches, merge and rebase, remotes, undo, stash, tags). Type a keyword in the search bar — a command name (rebase), a concept (“undo”, “merge”) or a category — to filter the list in real time, then click “Copy” next to the command you want to paste it directly into your terminal.
What is the difference between git fetch and git pull?
git fetch downloads new references from the remote repository without changing your local branch, giving you time to inspect the changes before integrating them. git pull does the same thing and then automatically merges (or rebases, depending on your configuration) those changes into your current branch.
When should I use git reset instead of git revert?
Use git reset to rewrite the history of a branch that hasn't been shared yet (or carefully, in coordination with your team), and git revert to cleanly undo a commit that has already been pushed and may be in use by others, since it adds a new undo commit without rewriting the existing history.
This cheatsheet is completely static and works offline once the page is loaded: no data is sent to a server, including your search.