Git Quick Reference
The commands I reach for every day.
Repository setup
git init # new repo
git clone <url> # clone remote
git clone --recurse-submodules # with submodulesStaging & committing
git status # what's changed
git add . # stage all
git add -p # interactive staging
git commit -m "message"
git commit --amend # edit last commitBranching
git branch # list branches
git branch <name> # create branch
git checkout -b <name> # create + switch
git switch <name> # switch (modern)
git branch -d <name> # deleteRemote
git remote -v # list remotes
git fetch # fetch without merging
git pull # fetch + merge
git push origin <branch>
git push -u origin <branch> # set upstreamUndo
git restore <file> # discard working tree changes
git reset HEAD <file> # unstage
git reset --soft HEAD~1 # undo last commit (keep changes)
git revert <hash> # safe undo (creates new commit)
