Home > Back-end >  git config --list has two entries for user.name
git config --list has two entries for user.name

Time:09-27

I don't know how I've ended up at this stage but on my Mac, using the terminal, if I enter git config --list, I obtain

credential.helper=osxkeychain
init.defaultbranch=main
[email protected]
user.name=username1
.
.
.
remote.origin.fetch= refs/heads/*:refs/remotes/origin/*
user.name=username2

Why are there two user.name entries and how do I remove username2? The source of this problem was trying to set up two GitHub credentials, one for work (username1) and one for personal (username2).

If I try git config user.name "username1", then I get

credential.helper=osxkeychain
init.defaultbranch=main
[email protected]
user.name=username1
.
.
.
remote.origin.fetch= refs/heads/*:refs/remotes/origin/*
user.name=username1

which is better but there's still two entries!

CodePudding user response:

I suspect you have one name in your global git config (not on my mac, but may be ~/.gitconfig) and another in the repo config. Personally, I'd just edit whichever of the two config files you want gone using git config -e with or without --global

Haven't used github recently, but I assume it is like other sites. For ssh, the authentication name goes in the repo url - user@host/repo.

CodePudding user response:

You can unset the name with this command:

git config --unset user.name

And maybe you can find something to be able to create a working and personal environment

Multiple GitHub accounts on the same computer?

  • Related