Git essentials
The 90% of Git you use daily — plus the "undo" commands worth memorising before you need them.
Branch & switch
git switch -c featureCreate a new branch and switch to it (modern; = checkout -b).git switch mainSwitch to an existing branch.git branch -d featureDelete a merged branch.Commit
git add -pStage changes interactively, hunk by hunk.git commit -m "msg"Commit staged changes with a message.git commit --amendFix the last commit (message or contents) — before pushing.Undo safely
git restore fileDiscard unstaged changes to a file.git reset --soft HEAD~1Undo the last commit, keep changes staged.git revert <sha>Create a new commit that undoes an old one (safe on shared branches).Remotes
git pull --rebaseUpdate your branch, replaying your commits on top (cleaner history).git push -u origin featurePush and set the upstream for a new branch.git log --oneline --graphA compact, visual history.