Basics

CommandPurpose
git status -sbShort branch-aware status
git diffUnstaged changes
git diff --stagedStaged changes
git add -pInteractive stage hunks
git commit --amendRewrite last commit (use carefully if pushed)

Branches

CommandPurpose
git switch -c feature/xCreate and checkout branch
git branch -vvList with upstream tracking
git merge --no-ff feature/xMerge preserving branch bubble
git rebase mainReplay current branch on top of main

Undo & recovery

CommandPurpose
git restore fileDiscard unstaged changes (2.23+)
git restore --staged fileUnstage
git reset --soft HEAD~1Drop last commit, keep changes staged
git reflogFind lost commits after rebase/reset

Stash & remote

git stash push -m "wip" -- path/to/file
git pull --rebase origin main
git push -u origin feature/x