Git Cheatsheet
Runs in browserComplete Git commands reference. Search across 50+ commands by category.
Complete Git commands reference with descriptions. Search any git command instantly. Covers setup, staging, committing, branching, remote, stashing, history, undoing, and advanced commands.
Git Cheatsheet tool
Click any command to copy · 54 commands across 9 categories
Setup6
git config --global user.name "Name"Set your global usernamecopygit config --global user.email "email"Set your global emailcopygit config --listList all configuration settingscopygit initInitialize a new local repositorycopygit clone <url>Clone a remote repositorycopygit clone <url> --depth 1Shallow clone (latest commit only)copyStaging7
git statusShow working tree statuscopygit add <file>Stage a specific filecopygit add .Stage all changes in current directorycopygit add -pStage changes interactively (hunk by hunk)copygit reset HEAD <file>Unstage a file, keep changescopygit diffShow unstaged changescopygit diff --stagedShow staged changes (vs last commit)copyCommitting4
git commit -m "msg"Commit staged changes with messagecopygit commit --amendAmend the last commit (message or files)copygit commit -am "msg"Stage tracked files + commitcopygit revert <hash>Create a new commit that undoes a commitcopyBranching9
git branchList all local branchescopygit branch <name>Create a new branchcopygit checkout <branch>Switch to a branchcopygit checkout -b <branch>Create and switch to a new branchcopygit switch <branch>Switch branch (modern syntax)copygit switch -c <branch>Create and switch (modern syntax)copygit merge <branch>Merge a branch into the current branchcopygit branch -d <branch>Delete a merged branchcopygit branch -D <branch>Force-delete a branchcopyRemote7
git remote -vList remote connectionscopygit remote add origin <url>Add a remote named origincopygit fetchDownload changes without mergingcopygit pullFetch and merge remote changescopygit pushPush commits to remotecopygit push -u origin <branch>Push and set upstream trackingcopygit push --force-with-leaseSafe force push (fails if remote changed)copyStashing5
git stashStash current working changescopygit stash popApply latest stash and remove itcopygit stash applyApply latest stash (keep stash)copygit stash listList all stashescopygit stash dropDelete the latest stashcopyHistory6
git logShow commit historycopygit log --onelineCompact one-line logcopygit log --graph --onelineVisual branch graphcopygit show <hash>Show details of a commitcopygit blame <file>Show who changed each linecopygit bisect startStart binary search for a bugcopyUndoing4
git reset --soft HEAD~1Undo last commit, keep changes stagedcopygit reset --hard HEAD~1Undo last commit, discard all changescopygit clean -fdRemove untracked files and directoriescopygit restore <file>Discard changes in working directorycopyAdvanced6
git cherry-pick <hash>Apply a specific commit to current branchcopygit rebase <branch>Rebase current branch onto anothercopygit rebase -i HEAD~3Interactive rebase (last 3 commits)copygit tag <name>Create a lightweight tagcopygit tag -a <name> -m "msg"Create an annotated tagcopygit submodule add <url>Add a submodule to the repositorycopy🔒 Runs in your browser · No uploads · Your data never leaves your device
How to use
Search for a command
Type in the search box to filter by command name, description, or category.
Browse by category
Commands are grouped into Setup, Staging, Committing, Branching, Remote, Stashing, History, Undoing, and Advanced.
Copy any command
Click any command row to copy it to your clipboard instantly.
Common use cases
- Looking up an infrequently used Git command — Search by keyword to find the exact command syntax for stashing, rebasing, or cherry-picking without leaving the browser.
- Onboarding new developers to Git — Share the cheatsheet as a quick reference for common Git workflows and branch management commands.
Examples
Undo last commit
Keep changes staged.
Outputgit reset --soft HEAD~1
Frequently asked questions
- What is the difference between git switch and git checkout?
- git switch is the modern replacement for git checkout for branch operations. git checkout still works but does too many things. Use git switch for branches and git restore for file changes.
- When should I use rebase vs merge?
- Use merge to preserve history. Use rebase to keep a linear commit history. Never rebase commits that have been pushed to a shared branch.
- What does --force-with-lease do?
- It is a safer alternative to --force-push. It fails if someone else has pushed to the branch since your last fetch, preventing accidental overwrites.
Key concepts
- Rebase
- A Git operation that moves or reapplies commits on top of another branch, creating a linear commit history.
- Stash
- Temporarily saves uncommitted changes so you can switch branches, then restore them later with git stash pop.
Related tools
You might find these useful too.