git configuration
git user settings
git name and email
version control
software development

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.

Browse interview questions

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:

bash
git config --global user.name "Ada Lovelace"
git config --global user.email "[email protected]"

That writes the values to your global Git config file, which is typically in your home directory.

You can verify the result with:

bash
git config --global --get user.name
git config --global --get user.email

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.

bash
git config user.name "Ada Lovelace"
git config user.email "[email protected]"

Because these commands omit --global, Git stores them in the repository’s local .git/config file.

To inspect the effective values in that repository:

bash
git config --get user.name
git config --get user.email

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:

bash
git config --show-origin --get user.name
git config --show-origin --get user.email

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:

ini
[user]
    name = Ada Lovelace
    email = [email protected]

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:

bash
git -c user.name="Release Bot" -c user.email="[email protected]" commit -m "Cut release"

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.name and user.email globally for your default identity.
  • Use local repository config when a project needs a different author identity.
  • Verify active values with git config --get and git config --show-origin.
  • Prefer git config commands over manual file editing for routine changes.
  • Treat commit identity, authentication, and hosting-platform account setup as separate concerns.

Related reading
Free course
Beginner
7 lessons
2 hours
Tackling System Design Interview Problems

A short course that equips you with the skills to approach system design interviews methodically.

Start the free course
Track 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.

Browse interview questions

All Rights Reserved.