Git Cheat Sheet
Searchable reference of the Git commands you forget — commit, branch, merge, rebase, stash and undo — in plain language with one-click copy. Free, no signup.
Setup & Config
git initgit clone <url>git config --global user.name "Your Name"git config --global user.email "you@example.com"git config --listStaging
git statusgit add <file>git add .git add -pgit restore --staged <file>git rm <file>Commit
git commit -m "message"git commit -am "message"git commit --amendgit commit --amend --no-editgit commit --allow-empty -m "message"Branches
git branchgit branch <name>git switch <name>git switch -c <name>git checkout <branch>git branch -d <name>git branch -m <old> <new>Merge & Rebase
git merge <branch>git merge --no-ff <branch>git rebase <branch>git rebase -i <base>git rebase --continuegit rebase --abortgit cherry-pick <commit>Remote
git remote -vgit remote add <name> <url>git fetch <remote>git pullgit pushgit push -u origin <branch>git push --force-with-leaseUndo & Reset
git restore <file>git reset --soft HEAD~1git reset --mixed HEAD~1git reset --hard HEAD~1git reset HEAD~<n>git fetch origin
git reset --hard origin/<branch>git revert <commit>git clean -fdgit reflogStash
git stashgit stash -ugit stash listgit stash popgit stash applygit stash dropLog & Diff
git loggit log --onelinegit log --graph --oneline --allgit diffgit diff --stagedgit show <commit>git blame <file>Tags
git taggit tag <name>git tag -a <name> -m "message"git push origin <tag>git push --tagsgit tag -d <name>🔒 Runs in your browser — nothing is uploaded.
Every Git command you forget, one search away
Type part of a command or what you want to do — like rebase, stash or undo — and the list filters instantly. Commands are grouped by task: setup, staging, commit, branches, merge and rebase, remote, undo, stash, log and tags. Each row has a short plain-language note and a one-click Copy button. It is a static reference that runs entirely in your browser, so nothing you type is uploaded.
Reset vs revert, merge vs rebase
The commands people mix up are here side by side: git reset --soft, --mixed and --hard for undoing commits, git revert for undoing a commit safely on a shared branch, and git rebase versus git merge for integrating branches. Search "undo" to compare the safe options, or "push" to see remote and tag pushes together.
Frequently asked questions
What is the difference between git reset and git revert?
git reset moves the branch pointer and can drop commits or changes locally, so it rewrites history. git revert adds a new commit that undoes an earlier one, which is safe on a branch other people have already pulled.
When should I use git rebase instead of git merge?
Use rebase to keep a linear history by replaying your commits on top of the latest branch, which is handy before opening a pull request. Use merge to combine branches while preserving the exact history, especially on shared branches where rewriting is risky.
How do I undo my last commit but keep the changes?
Run git reset --soft HEAD~1 to remove the commit and leave everything staged, or git reset --mixed HEAD~1 to keep the changes but unstage them.
Is anything I search uploaded to a server?
No. The command list is static data bundled with the page and the search runs entirely in your browser, so nothing you type leaves your device.