Git name and email address configuration
Interview Questions practice on Codemia
Over 8,000 real interview questions from top companies, searchable by company and role.
Introduction
Every Git commit records author and committer metadata, so your configured name and email address become part of the project history. Getting those values right matters for attribution, signing workflows, corporate compliance, and simply making sure your teammates can tell who made which change.
The Three Git Configuration Levels
Git settings can exist at three scopes:
- system, which affects all users on the machine
- global, which affects your user account
- local, which affects one repository only
If the same setting exists in more than one place, Git uses the most specific one. Local overrides global, and global overrides system.
For most developers, global settings are the baseline and local settings are used only when a repository needs different identity data.
Set Your Global Name and Email
The most common setup is:
That writes the values to your global Git config file, which is typically in your home directory.
You can verify the result with:
If you only use one Git identity on the machine, this is usually enough.
Override Identity for One Repository
Sometimes you need a different email or name for a specific repository, such as company work versus personal open-source work. In that case, set the values locally inside the repository directory.
Because these commands omit --global, Git stores them in the repository’s local .git/config file.
To inspect the effective values in that repository:
This is the safest way to use separate identities without constantly editing your global settings.
See Where a Value Comes From
When configuration gets confusing, ask Git for both the value and its source file:
That command is underrated. It tells you not only what the current value is, but also whether it came from a system file, your global config, or the current repository.
If the value is wrong, you now know exactly where to fix it.
Editing Config Files Directly
Git config commands are the normal interface, but you can also open the files directly.
A global config file usually contains entries like this:
A local repository config looks similar, but it lives under .git/config.
Direct editing is fine, but git config is safer because it handles formatting for you.
Author vs Committer and Why It Matters
Most day-to-day usage only worries about user.name and user.email, but Git stores both author and committer identity in each commit.
Normally those values are the same. They can differ when:
- a patch is applied by someone else
- a commit is rebased or amended by another person
- tooling rewrites history in automation
For ordinary commit creation, configuring user.name and user.email correctly is the important part.
Temporary Overrides for One Command
If you need a one-off commit under a different identity, you can override configuration just for that invocation:
This is useful in scripts or release tooling where you do not want to mutate the repository’s persistent configuration.
Common Pitfalls
The biggest pitfall is setting a global identity and forgetting that one repository already has a local override. Git will keep using the local value.
Another common issue is assuming your hosting platform email and your Git commit email must always match exactly. Some platforms map multiple verified emails to one account, while others require specific addresses for attribution.
Developers also sometimes edit the wrong config file manually and then wonder why nothing changed. --show-origin solves that quickly.
Finally, do not confuse authentication with authorship. SSH keys, access tokens, and Git author metadata are related operationally, but they are separate mechanisms.
Summary
- Set
user.nameanduser.emailglobally for your default identity. - Use local repository config when a project needs a different author identity.
- Verify active values with
git config --getandgit config --show-origin. - Prefer
git configcommands over manual file editing for routine changes. - Treat commit identity, authentication, and hosting-platform account setup as separate concerns.
Related reading
- Git Needed a single revision error
- Git number of commits per author on all branches
- Git on Windows How do you set up a mergetool?
- git partial merge, not whole branch
- Git please tell me who you are error
- Git pre-commit hook changed/added files
- git pull --rebase leads to Cannot rebase onto multiple branches
- Git pull after forced update
.png&w=3840&q=75)
Tackling System Design Interview Problems
A short course that equips you with the skills to approach system design interviews methodically.
Start the free courseTrack what you have practised
A free account saves your progress, solutions and study plan across every problem on Codemia.
Interview Questions practice on Codemia
Over 8,000 real interview questions from top companies, searchable by company and role.