Chapter 1 · Practice 4 of 4
Set your identity and a few helpful defaults once
Why it matters
A few settings, made once with git config --global, make every commit attributed correctly and remove small daily annoyances.
Use the same email as your GitHub or GitLab account so commits link to your profile.
| Setting | What it does |
|---|---|
user.name, user.email | Attribute your commits correctly |
init.defaultBranch | New repositories start with the branch name your team uses |
push.autoSetupRemote | Sets the upstream on your first push of a new branch |
rerere.enabled | Git remembers how you resolved a conflict and reuses the resolution next time |
See the git-config documentation for every option.
Example
git config --global user.name "Your Name"
git config --global user.email "you@example.com"
git config --global init.defaultBranch main
git config --global push.autoSetupRemote true
git config --global rerere.enabled true