Git Cheat Sheet
A searchable Git command reference grouped by task — branching, remotes, undoing, stash, rebase, worktree — with one-click copy.
Placeholders
<branch>, <file>, <remote> and <commit> are placeholders — replace them with your own names. Commands that rewrite history are marked rewrites history; avoid them on branches other people have already pulled.
No command matches that search.
How to use this Git cheat sheet
- Type what you want to do — "undo", "rename branch", "stash" — and the list filters as you type, in English or Chinese.
- Jump straight to a section with the category chips: branching, remotes, undoing changes, rebase, worktree and more.
- Press the copy button next to a command, paste it into your terminal and replace the
<placeholders>with your own branch and file names.
FAQ
Which commands are dangerous?
Anything marked rewrites history — git rebase, git commit --amend, git reset --hard and force pushes. They are perfectly safe on commits that only exist on your machine, but they break other people's clones once the commits have been pushed and pulled.
How do I undo the last commit but keep my changes?
git reset --soft HEAD~1 moves the branch back one commit and leaves everything staged. Use --mixed (the default) to unstage them as well, and --hard only when you really want the changes gone.
Does this page send anything anywhere?
No. It is a static reference — the search and the copy button run entirely in your browser, and nothing you type is recorded or uploaded.