How to use the Git cheat sheet
- Type a task or keyword into Filter, such as
undo,stash,last commitorupstream. Every word must appear in the command, its description or its topic. - Or choose a Topic: Setup, Basics, Branches, Remotes, History, Undo, Stash, Tags or Advanced. Leave it on All topics to search everything.
- Read the Command and What it does columns. Words in angle brackets, such as
<branch>, are placeholders. - Download the list as
git-cheatsheet.csvto keep with your team’s docs.
What it does and when to use it
Most Git work uses a small set of commands, but the ones you need rarely, such as undoing a commit, renaming a branch or deleting a remote branch, are easy to forget and risky to guess. This cheat sheet is organised by intent, so you can search for what you want to happen rather than the exact flag. It suits beginners learning the daily loop of status, add, commit and push, and experienced developers who need the exact form of rebase -i or stash apply stash@{1}.
For writing commit messages in a consistent format, use the Conventional Commit Generator. To keep build output out of the repository, the Gitignore Generator writes a starting .gitignore.
How it works
The list holds 62 commands in nine topics: Setup 6, Basics 9, Branches 12, Remotes 9, History 7, Undo 7, Stash 5, Tags 3 and Advanced 4. It uses current command names, git switch and git restore, alongside long-standing ones such as git reset. Your filter is split into words, each matched without regard to case, then the topic menu narrows the result. Nothing is sent anywhere and no Git commands run.
Worked examples
Undo something. Filter undo returns 7 rows, all in the Undo topic, including:
git reset --soft HEAD~1 | Undo the last commit, keep its changes staged. | Undo
git revert <commit> | Create a new commit that undoes a commit — safe on shared branches. | Undo
Working with a remote. Topic Remotes with an empty filter returns Showing: 9 of 62 commands, from git remote -v to git push origin --delete <branch>.
A safe force push. Filter force finds two commands: git branch -d <name> (whose note says -D forces deletion) and git push --force-with-lease.
Limits and tips
- Each row is one common form. Run
git help <command>orgit <command> -hfor all options. - Commands that rewrite history (
rebase,commit --amend,reset) are fine on your own branch but need care once others have pulled it. - To compare two versions of a file outside Git, use the Diff Checker. For shell commands around Git, see the Linux Commands Ref.
Frequently asked questions
How do I undo the last commit but keep my work?
What is the difference between git switch, git restore and git checkout?
Why use --force-with-lease instead of --force?
Which commands lose work?
Does the cheat sheet run Git?
How do we know nothing is uploaded? Test it yourself on the privacy proof page.