More than one value for the key user.name Git

If you just want to reset all of them:

git config --global --replace-all user.email "[email protected]"

Update (December 2012)

git1.8.1rc1 now operates differently:

"git config --get" used to diagnose presence of multiple definitions of the same variable in the same configuration file as an error, but it now applies the "last one wins" rule used by the internal configuration logic.

Strictly speaking, this may be an API regression but it is expected that nobody will notice it in practice.


Original answer (November 2010)

The git config man page mentions:

The variable names are case-insensitive and only alphanumeric characters and - are allowed.
There can be more than one value for a given variable; we say then that variable is multivalued.

Actually, such config settings (with multiple possible values) are called multivar

As Jefromi suggests, see in what of the 3 config files you have more than one user.name line.
You can query multiple values like so:

git config --local  --get-all user.name #local repo git config file)
git config --global --get-all user.name #user config file)
git config --system --get-all user.name #system git config file)

The one config file which answers more than one user.name value needs to be fixed.


From the comments:

Examining files "local", "global" and "settings" I can see only one user.name in global.
But git config --list and git config --get-all user.name gives it twice to me

As I mention in here with Git 2.8 (March 2016), you can use (to see all settings:

git config -l --show-origin

One you see where the duplicate setting is (local, global, system), you can use git config [--local/--global/--system] --replace-all key value, as in mb21's answer.


You should examine the contents of ~/.gitconfig (your user-global config) as well as .git/config in the repository in question (the repo-specific config). You should see two name lines under a user section in one of them. (It could also be two separate user sections in one file.) Just delete the one you don't want, and you should be good to go.

You could also directly set it with git config --global user.name "Desired name" if you want it to be a global setting (probably the case), or the same minus the --global for a repo-specific setting - but it's probably best to inspect the files and find the culprit yourself, to make sure you know what you have. The repo-specific one will override the global one. Ideally you should set your name globally, and only override it in a project for a good reason.