How to Configure Git Settings (git config)
git config reads and writes configuration values that control how Git behaves, such as your identity and command aliases.
Published September 29, 2026
git config reads and writes Git settings at three levels: system, global (your user) and local (the repository). Local overrides global, global overrides system.
How it works
Common settings: user.name, user.email, default branch, editor, aliases and pull behaviour.
The values are stored in plain text files such as ~/.gitconfig and .git/config.
Try it
git config --global user.name "Ada"
git config --global user.email ada@example.com
git config --list --show-origin
Practical examples
Identity
git config --global user.name "Ada Lovelace"
git config --global user.email ada@example.comDefault branch and pull
git config --global init.defaultBranch main
git config --global pull.rebase trueAliases
git config --global alias.st status
git config --global alias.co switchPer-repo email
git config user.email work@example.comCommon mistakes
- Committing with the wrong email.
- Editing .git/config incorrectly by hand.
- Confusing global and local scope.
Key takeaways
- Three levels: system, global, local.
- Local wins.
- Set identity before the first commit.
FAQ
Where is the file?
~/.gitconfig (global) and .git/config (local).
How do I see a value's source?
git config --show-origin <key>.