Git Command Cheatsheet
Quick reference for common Git commands, covering basics, branching, remotes, undo, and more. 100% free, no signup, runs locally in your browser—nothing is uploaded to our servers.
Basic
git init— Initialize a new repositoryClick to copygit clone <url>— Clone a remote repositoryClick to copygit status— Show working tree statusClick to copygit add <file>— Stage file(s) for commitClick to copygit add .— Stage all changesClick to copygit commit -m "msg"— Commit staged changesClick to copygit diff— Show unstaged changesClick to copygit diff --staged— Show staged changesClick to copyBranch
git branch— List local branchesClick to copygit branch <name>— Create a new branchClick to copygit checkout <branch>— Switch to branchClick to copygit checkout -b <name>— Create & switch to branchClick to copygit switch <branch>— Switch to branch (new)Click to copygit switch -c <name>— Create & switch (new)Click to copygit merge <branch>— Merge branch into currentClick to copygit branch -d <name>— Delete a branchClick to copygit branch -m <old> <new>— Rename a branchClick to copyRemote
git remote -v— List remote repositoriesClick to copygit remote add <name> <url>— Add a remoteClick to copygit fetch— Fetch from remoteClick to copygit pull— Fetch & mergeClick to copygit push— Push to remoteClick to copygit push -u origin <branch>— Push & set upstreamClick to copygit remote remove <name>— Remove a remoteClick to copyUndo/Reset
git reset HEAD <file>— Unstage a fileClick to copygit checkout -- <file>— Discard working changesClick to copygit restore <file>— Discard working changes (new)Click to copygit reset --soft HEAD~1— Undo last commit, keep stagedClick to copygit reset --mixed HEAD~1— Undo last commit, keep unstagedClick to copygit reset --hard HEAD~1— Undo last commit, discard allClick to copygit revert <commit>— Create undo commitClick to copyStash
git stash— Stash current changesClick to copygit stash list— List stashesClick to copygit stash pop— Apply & remove latest stashClick to copygit stash apply— Apply latest stashClick to copygit stash drop— Remove latest stashClick to copygit stash push -m "msg"— Stash with a messageClick to copyLog
git log— Show commit historyClick to copygit log --oneline— Compact commit historyClick to copygit log --graph— Graph of branchesClick to copygit log -n <count>— Show last N commitsClick to copygit show <commit>— Show commit detailsClick to copygit blame <file>— Line-by-line historyClick to copyTag
git tag— List tagsClick to copygit tag <name>— Create lightweight tagClick to copygit tag -a <name> -m "msg"— Create annotated tagClick to copygit tag -d <name>— Delete a tagClick to copygit push origin --tags— Push tags to remoteClick to copy