How to Change My Git Username in Terminal?
I Was Pushing and Pulling from Git in Terminal Then I Changed My Username on Github. Com. I Went to Push Some Changes and It Couldn't Push Because It Was Still...
I was pushing and pulling from git in Terminal then I changed my username on github.com. I went to push some changes and it couldn't push because it was still recognizing my old username.. How do I change/update my username on git in terminal?
18 Answers
- In your terminal, navigate to the repo you want to make the changes in.
- Execute
git config --listto check current username & email in your local repo. - Change username & email as desired. Make it a global change or specific to the local repo:
git config [--global] user.name "Full Name"
git config [--global] user.email ""Per repo basis you could also edit
.git/configmanually instead. - Done!
When performing step 2 if you see credential.helper=manager you need to open the credential manager of your computer (Win or Mac) and update the credentials there
Here is how it look on windows
Troubleshooting? Learn more
You probably need to update the remote URL since github puts your username in it. You can take a look at the original URL by typing
git config --get remote.origin.url
Or just go to the repository page on Github and get the new URL. Then use
git remote set-url origin url with username replaced}
to update the URL with your new username.
- EDIT: In addition to changing your name and email You may also need to change your credentials:
To change locally for just one repository, enter in terminal, from within the repository
git config credential.username "new_username"To change globally use
git config --global credential.username "new_username"(EDIT EXPLAINED: If you don't change also the
user.emailanduser.name, you will be able to push your changes, but they will be registered in git under the previous user)
Next time you
push, you will be asked to enter your passwordPassword for '
there are 3 ways we can fix this issue
Must Read
method-1 (command line)
To set your account's default identity globally run below commands
git config --global user.email ""
git config --global user.name "Your Name"
git config --global user.password "your password"
To set the identity only in current repository , remove --global and run below commands in your Project/Repo root directory
git config user.email ""
git config user.name "Your Name"
git config user.password "your password"
Example:
email -> organization email Id
name -> mostly <employee Id> or <FirstName, LastName>
**Note: ** you can check these values in your GitHub profile or Bitbucket profile