Git has hundreds of commands and flags. You will use about fifteen of them for 95% of your work. This is that fifteen — the 'what's the git command for…' cheat sheet, each one with the situation it's for.
See what's going on
git status # what's staged, modified, untracked
git log --oneline # compact commit history
git diff # unstaged changes
git diff --staged # what you're about to commitStage and commit
git add file.ts # stage one file
git add . # stage everything (careful — check status first)
git commit -m "feat: add login form"
git commit --amend # fix the last commit (if not pushed)Branch and switch
git branch # list branches
git switch -c feature/login # create AND switch to a new branch
git switch main # switch to an existing branch
git branch -d feature/login # delete a merged branchgit switch (newer) is clearer than the overloaded git checkout. Use switch for branches, restore for files — the old checkout did both and confused everyone.
Sync with the remote
git pull # fetch + merge the remote's changes
git pull --rebase # ...but keep history linear
git push # push your commits
git push -u origin feature/x # first push of a new branch (sets upstream)Undo the common mistakes
git restore file.ts # discard unstaged changes to a file
git restore --staged file.ts # unstage (keep changes)
git reset --soft HEAD~1 # undo last commit, keep changes staged
git revert <hash> # safely undo a pushed commitStash work in progress
git stash # shelve uncommitted changes
git stash pop # bring them back
git stash list # see what you've stashedSet a few aliases and these get faster: git config --global alias.co switch, alias.st status, alias.lg 'log --oneline --graph --decorate'.
Learn these fifteen and you'll rarely need to Google a Git command again. Everything else — cherry-pick, bisect, reflog — you look up the handful of times a year you actually need it.