Git

Git Commit Author Showing Wrong Name or Email

Commits showing the wrong name or email almost always mean Git's user configuration wasn't set correctly for the repository (or globally) at the time the commit was made — Git uses whatever user.name and user.email are configured at commit time, with no verification against any account you're actually logged into anywhere.

The Problem

Checking recent commit history reveals the wrong author information:

git log -1
Author: Your Old Name <old.email@example.com>

Even though you expected your current name and email to be used, based on what you remember configuring previously.

Why It Happens

Git's identity configuration works at several levels, and confusion about which one is actually active is the most common cause:

  • Global config (git config --global) sets a default identity for all repositories on your machine, but a repository-specific local config, if it exists, overrides it for that specific repository only
  • You configured your identity on a different machine, or in a different user account on a shared machine, and the current environment has different (or no) configuration set
  • A repository was cloned with a local config already committed to a shared config file, or set up by a script/onboarding process using placeholder values that were never updated
  • You're using a Git GUI tool or IDE integration that has its own separate identity configuration, independent of what's set via the command line

The Fix

First, check both your global and local (repository-specific) configuration to see which values are actually active right now:

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

git config --local user.name
git config --local user.email

Local config, if set, always takes precedence over global config within that specific repository. If the local values are wrong or unexpectedly set, update them directly:

git config --local user.name "Your Correct Name"
git config --local user.email "your.correct@email.com"

If you want to remove a local override entirely and fall back to your global configuration:

git config --local --unset user.name
git config --local --unset user.email

To set your global default identity, used for any repository without its own local override:

git config --global user.name "Your Correct Name"
git config --global user.email "your.correct@email.com"

These changes only affect future commits — commits already made with the wrong identity aren't automatically corrected. To fix the most recent commit's author information:

git commit --amend --author="Your Correct Name <your.correct@email.com>" --no-edit

The --no-edit flag keeps the existing commit message unchanged while only updating the author information.

To fix author information across multiple past commits (not just the most recent one), an interactive rebase lets you amend each affected commit individually:

git rebase -i HEAD~5

Mark each commit you need to fix with edit instead of pick, then for each one, run the amend command above before continuing the rebase with git rebase --continue.

If commits have already been pushed to a shared branch, be aware that amending or rebasing rewrites commit hashes, requiring a force push and coordination with anyone else who might have already pulled the affected commits — this isn't a step to take lightly on a branch others are actively working from.

Still Not Working?

If you're using a Git GUI tool or IDE and the wrong identity keeps appearing despite correct command-line configuration, check that tool's own separate Git identity settings, since some GUI clients maintain their own configuration independent of (or overriding) what's set via git config directly. Confirming which identity source is actually taking effect for a specific commit is easiest by making a test commit through each method (command line vs. GUI) and comparing the resulting author information directly.

It's also worth checking whether the wrong identity is coming from a system-level or administrator-configured Git config file, separate from your own user-level global config. Git checks configuration at multiple levels — system, global, and local, in increasing order of precedence — and on a shared or company-managed machine, a system-level config file might set defaults you're not aware of that only your local repository-level config can override:

git config --list --show-origin

This command shows every configuration value currently in effect along with exactly which file each one came from, making it straightforward to identify whether an unexpected system or global file is the actual source of a wrong identity, rather than something in the repository itself.

Finally, if you work across multiple identities regularly (a personal GitHub account and a separate work account, for example), consider using Git's conditional includes feature, which automatically applies different identity configuration based on the directory a repository lives in, removing the need to manually set local config for every single repository:

# ~/.gitconfig
[includeIf "gitdir:~/work/"]
    path = ~/.gitconfig-work