Before your first commit, Git wants to know who you are. Configuration lives in three scopes:
- system:
/etc/gitconfig — every user on the machine.
- global:
~/.gitconfig — your personal defaults across all repos. Use --global.
- local:
.git/config — overrides for this one repository. Default scope.
Essentials to set once globally:
git config --global user.name "Your Name"
git config --global user.email "you@domain.com"
git config --global init.defaultBranch main
git config --global core.editor "code --wait"
Per-repo overrides let you use a work email at ~/work/ and a personal one at ~/oss/.
List everything with git config --list --show-origin — the right-hand side tells you which file each value came from.