Github commits linked to the wrong user [Solved]

I have been using my Ubuntu desktop for a long time and all my commits were getting deployed to github remote repo without any issue. Few days back, someone else used my machine for few days. Now when I am pushing any code to guthib, its asking my for credentials but when I am checking my github repository, a different users name is displayed.

check current user configured by following command

$ git config --global --list
user.name=FirstName LastName
user.email=FirstName.LastName@gmail.com
push.default=simple

We need to change it. It can be changed by two ways

  1. By editing .gitconfig file

.gitconfig is located in your home directory. File content is as below

[user]
     name = FirstName.LastName@gmail.com
     email = FirstName.LastName@gmail.com
[push] 
    default = simple

You can simply edit the file to required name and email.

You can open this file using following command as well


git config --global -e

2.  Changing details using command line

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

You can add required details as below

git config --global --add user.name <YourGithubUserName>
git config --global --add user.email <YourGithubemail>

if you want to change user names without resetting


git config --global user.name <YourGithubUserName>
git config --global user.email <YourGithubemail>

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.