Download and Installation

Quick start (most-used)

git status
git add .
git commit -m "message"
git pull --rebase
git push

Config

Identity

git config --global user.name "Bendy Zhang"
git config --global user.email "[email protected]"
git config --global --list

Helpful defaults

git config --global init.defaultBranch main
git config --global pull.rebase true
git config --global rebase.autoStash true
git config --global fetch.prune true
git config --global rerere.enabled true

Ignore files globally

git config --global core.excludesfile ~/.gitignore_global
# edit ~/.gitignore_global

Workspace (working tree / index / HEAD)

Check workspace status

git status
git diff            # workspace vs index
git diff --staged   # index vs HEAD

Move changes between workspace and staging

git add <file>
git add -p
git restore --staged <file>   # unstage

Discard workspace changes (dangerous)