Git Reference
Git Reference / Setup & config

02Setup & config

Config lives at three levels: --system, --global (your user), and --local (this repo). More specific wins.

Identity

Stamped on every commit you make.

git config --global user.name "Your Name"
git config --global user.email "you@example.com"

Sensible defaults

Modern settings worth turning on.

git config --global init.defaultBranch main
git config --global pull.rebase true
git config --global push.autoSetupRemote true
git config --global rerere.enabled true
git config --global core.editor "code --wait"

Aliases

Shortcuts for commands you type constantly.

git config --global alias.st "status -sb"
git config --global alias.lg "log --oneline --graph --all --decorate"
git config --global alias.undo "reset --soft HEAD~1"

Inspect config

See every value and which file set it.

git config --list --show-origin
git config --global --edit

SSH key for GitHub

Authenticate without passwords.

ssh-keygen -t ed25519 -C "you@example.com"
cat ~/.ssh/id_ed25519.pub   # paste into GitHub → Settings → SSH keys
ssh -T git@github.com

Sign commits

Show a “Verified” badge using your SSH key.

git config --global gpg.format ssh
git config --global user.signingkey ~/.ssh/id_ed25519.pub
git config --global commit.gpgsign true