Basics
git init # create a new repository
git clone <url> # copy a remote repository
git status # show changed files
git add <file> # stage a file
git commit -m "message" # commit staged changes
Branches
git branch # list branches
git branch <name> # create a branch
git checkout <name> # switch branches
git checkout -b <name> # create and switch
git merge <name> # merge a branch into current
Remotes
git remote -v # list remotes
git push origin <branch> # push a branch
git pull origin <branch> # fetch and merge
git fetch # fetch without merging
Undoing Changes
git restore <file> # discard unstaged changes
git reset --soft HEAD~1 # undo last commit, keep changes staged
git revert <commit> # create a new commit that undoes one