Git commit with Wrong Username

Mousumi Sinha
2 min readMay 8, 2021
https://git-scm.com/images/logos/downloads/Git-Logo-2Color.png

As much as GitHub makes your life easier, it can turn out to become the most non intuitive code hosting platform if you don’t know where to look.

Couple of days back, I borrowed my husband’s laptop for some Proof Of Concept work. Everything was fine till the point I decided to push the code to GitHub. Like a smooth sail the code went through, the only problem being it was using his username instead of mine !

On googling a couple of articles, found that I can just remove his GitHub credentials from the credential manager. easy , right ?

Here’s how .

Removing the credential was pretty straight forward except for the fact it didn’t work.

Next I decided to leverage the help of git config. Unset the username that’s saved.

git config --global --unset user.name
git config --global --unset credential.helper

This didn’t work as well.

It was the git hub docs that gave a proper explanation to the problem .

If your commits are linked to another user, that means the email address in your local Git configuration settings is connected to that user’s account on GitHub. In this case, you can change the email in your local Git configuration settings and add the new email address to your GitHub account to link future commits to your account.

$ git config --global user.email "email@example.com"

Phew !! that worked finally.

--

--

Mousumi Sinha

Software Engineer | artist | avid reader | aspiring author | More to come.