Git Command Cheatsheet
Searchable reference of everyday Git commands for branching, undoing and inspecting history.
Setup & clone
git initStart a new repositorygit clone <url>Clone a remote repositorygit remote -vList remotesgit remote add origin <url>Add a remoteDaily flow
git status -sbShort status with branch infogit add -pStage changes hunk by hunkgit commit -m "msg"Commit staged changesgit commit --amend --no-editAdd to the last commitgit push -u origin HEADPush and track current branchgit pull --rebasePull and replay local commitsBranching
git switch -c feature/xCreate and switch to a branchgit switch mainSwitch branchgit branch -d feature/xDelete merged branchgit merge --no-ff feature/xMerge with a merge commitgit rebase mainRebase onto maingit cherry-pick <sha>Apply one commit elsewhereUndo & rescue
git restore <file>Discard working changesgit restore --staged <file>Unstage a filegit reset --soft HEAD~1Undo last commit, keep changesgit reset --hard origin/mainForce local to match remotegit revert <sha>Create an inverse commitgit reflogFind lost commitsgit stash push -m "wip"Stash work in progressgit stash popRestore stashed workInspect
git log --oneline --graph --allVisual commit graphgit diff --stagedDiff staged changesgit blame -L 10,20 <file>Who changed these linesgit show <sha>Inspect a commitgit bisect startBinary-search a bad commitCleanup
git clean -fdDelete untracked files & dirsgit gc --prune=nowGarbage collectgit fetch --pruneDrop deleted remote branchesgit rm --cached <file>Stop tracking a fileRelated tools
All →DEV/FORMAT
JSON Formatter
Prettify, minify, and validate JSON data strings instantly.
DEV/SQL
SQL Editor & Checker
Format SQL and lint for missing WHERE, unmatched quotes, and common mistakes.
DEV/AUTH
JWT Debugger
Decode and inspect JSON Web Token headers and payloads.
DEV/DIFF
JSON Diff
Compare two JSON objects and highlight added, removed, and changed keys.