Updated June 29, 2026
Git config reference
git config stores settings at the global level (your machine) or local level (one repo). These are the settings most people want to set once. Add --global to apply a setting everywhere.
Identity
| Command | What it does |
|---|---|
git config --global user.name "Your Name" | The name on your commits. |
git config --global user.email "you@example.com" | The email on your commits. |
Sensible defaults
| Command | What it does |
|---|---|
git config --global init.defaultBranch main | Name the first branch main in new repos. |
git config --global pull.rebase true | Rebase instead of merge on git pull. |
git config --global core.editor "code --wait" | Use VS Code for commit messages. |
git config --global core.autocrlf input | Normalize line endings (macOS/Linux). |
git config --global push.autoSetupRemote true | Auto-create the upstream branch on first push. |
Handy aliases
| Command | What it does |
|---|---|
git config --global alias.st status | git st runs git status. |
git config --global alias.co checkout | git co runs git checkout. |
git config --global alias.lg "log --oneline --graph" | git lg shows a compact graph log. |
Inspecting config
| Command | What it does |
|---|---|
git config --list | Show all effective settings. |
git config user.email | Show one setting's value. |
git config --global --edit | Open the global config file in your editor. |
Global vs local
--global settings live in your home directory and apply everywhere. Without it, the setting applies only to the current repository and overrides the global value.References
Questions
Where are global git settings stored?
In a file called .gitconfig in your home directory. You can edit it directly or with git config --global --edit.
How do I use a different email for one project?
Run git config user.email without --global inside that repository. The local setting overrides the global one for that project only.