DEVELOPER DESK REFERENCE
Git Everyday & Rescue Cheatsheet
GIT 2.40+
DAILY COMMIT FLOW
git status -sb
Compact branch & modified file view
git add -p
Interactively stage specific hunks
git commit -m "msg"
Commit staged changes cleanly
git commit --amend
Edit last commit message or add file
git pull --rebase
Fetch + replay your commits on top
git push -u origin HEAD
Push new branch & track upstream
BRANCHES & WORKTREES
git switch -c feat/x
Create and switch to new branch
git switch -
Jump back to previous branch
git merge --no-ff feat/x
Merge keeping branch history clear
git rebase main
Reapply current branch onto main
git branch -d feat/x
Safely delete already-merged branch
git worktree add ../hotfix
Check out 2nd branch in new folder
INSPECT, DIFF & STASH
git diff --staged
Review exact diff ready to commit
git log --oneline -n 12
Compact recent commit graph
git show <hash>
Inspect one commit's patch & author
git blame -L 10,30 file
See who last changed lines 10 to 30
git stash push -m "wip"
Shelve uncommitted edits safely
git stash pop
Re-apply latest stash and drop it
EMERGENCY UNDO & RESCUE
git restore file.ts
Discard unstaged edits to one file
git restore --staged .
Unstage everything (keep file edits)
git reset --soft HEAD~1
Undo last commit, keep changes staged
git revert <hash>
Safe public undo via inverse commit
git reflog
Every HEAD move from the past 90 days
git cherry-pick <hash>
Copy one specific commit here