Reputation: 5403
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?
Upvotes: 530
Views: 1439878
Reputation: 53
If you are accessing it from windows , after running the specific command that have been mentioned about username and password, do following thing :
Upvotes: 0
Reputation: 11
Remove these two credentials from Windows credentials managers. and then run the git command it will again pop up the login page where you can log in from a different account.
Upvotes: 0
Reputation: 12740
git config --list
to check current username & email in your local repo.git config --global user.name "Full Name"
git config --global user.email "[email protected]"
.git/config
manually instead.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
Upvotes: 678
Reputation: 12345
For the Github
git config --local user.name "another_username"
git config --local user.email "[email protected]"
git remote set-url origin https://[email protected]/repo_url
Upvotes: 7
Reputation: 5125
there are 3 ways we can fix this issue
To set your account's default identity globally
run below commands
git config --global user.email "[email protected]"
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 "[email protected]"
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
create a .gitconfig file in your home folder if it doesn't exist. and paste the following lines in .gitconfig
[user]
name = FirstName, LastName
email = [email protected]
password = abcdxyz
[http]
sslVerify = false
proxy =
[https]
sslverify = false
proxy = https://corp\\<uname>:<password>@<proxyhost>:<proxy-port>
[push]
default = simple
[credential]
helper = cache --timeout=360000000
[core]
autocrlf = false
Note: you can remove the proxy lines from the above , if you are not behind the proxy
Home directory to create .gitconfig file:
windows : c/users/< username or empID >
Mac or Linux : run this command to go to home directory cd ~
or simply run the following commands one after the other
git config --global --edit
git commit --amend --reset-author
windows :
Control Panel >> User Account >> Credential Manager >> Windows Credential >> Generic Credential
>> look for any github cert/credential and delete it.
then running any git command will prompt to enter new user name and password (Note: some times you will not be prompted for password for git pull).
Mac :
command+space >> search for "keychain Access" and click ok >>
search for any certificate/file with gitHub >> delete it.
then running any git command will prompt to enter new user name and password(Note:some times you will not be prompted for password for git pull).
Upvotes: 234
Reputation: 6152
In linux (Ubuntu 18.04) the username / password are saved as cleartext in the file ~/.git-credentials
, just edit the file to use your new username / password.
The file format is quiet easy, each line contains credentials for one user / domain, in the following format:
https://<username>:<password>@github.com
https://<username2>:<password2>@bitbucket.com
...
Upvotes: 2
Reputation: 133
I myself have recently faced the same problem. In my case I had two github accounts: work and personal. I wanted to push my starter code to the repository in my personal account but the global configuration had my work account. I didn't want to bother with reconfiguring the global every single time I had to switch between work and personal projects. So I used these commands to set my username and email for that specific personal project folder.
The solution:
$ git config user.name "Alex"
$ git config user.email "[email protected]"
$ git config credential.username "your_account_name_here"
Upvotes: 3
Reputation: 1366
git config [--global] user.name "Full Name"
git config [--global] user.email "[email protected]"
Per repo basis you could also edit .git/config
manually instead.
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
Upvotes: 4
Reputation: 31
If you have created a new Github account and you want to push commits with your new account instead of your previous account then the .gitconfig must be updated, otherwise, you will push with the already owned Github account to the new account.
In order to fix this, you have to navigate to your home directory and open the .gitconfig with an editor. The editor can be vim, notepad++, or even notepad.
Once you have the .gitconfig open, just modify the "name" with your new Github account username that you want to push with.
Upvotes: 0
Reputation: 951
**Check by executing this**
git config --list
**Change user email**
git config --global user.email "[email protected]"
**Change user name**
git config --global user.name "user"
**Change user credential name**
git config --global credential.username "new_username"
**After this a window popup asking password.
Enter password and proceed.**
Upvotes: 8
Reputation: 3117
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.email
and user.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 password
Password for 'https://<new_username>@github.com':
Upvotes: 213
Reputation: 496
If you have cloned your repo using url that contains your username, then you should also change remote.origin.url
property because otherwise it keeps asking password for the old username.
example:
remote.origin.url=https://<old_uname>@<repo_url>
should change to
remote.origin.url=https://<new_uname>@<repo_url>
Upvotes: 1
Reputation: 8063
Firstly you need to change credentials from your local machine
git config [--global] user.name "Your Name"
git config [--global] user.email "[email protected]"
Upvotes: 6
Reputation: 151
There is a easy solution for that problem, the solution is removed the certificate the yours Keychain, the previous thing will cause that it asks again to the user and password.
Steps:
Search the certificate gitHub.com.
Remove gitHub.com certificate.
Execute any operation with git in your terminal. this again ask your username and password.
For Windows Users find the key chain by following:
Control Panel >> User Account >> Credential Manager >> Windows Credential >> Generic Credential
Upvotes: 14
Reputation: 4691
usually the user name resides under git config
git config --global user.name "first last"
although if you still see above doesn't work you could edit .gitconfig under your user directory of mac and update
[user]
name = gitusername
email = [email protected]
Upvotes: 1
Reputation: 418
From your terminal do:
git config credential.username "prefered username"
OR
git config --global user.name "Firstname Lastname"
Upvotes: 16
Reputation: 2160
I recommend you to do this by simply go to your .git folder, then open config file. In the file paste your user info:
[user]
name = Your-Name
email = Your-email
This should be it.
Upvotes: 15
Reputation: 9141
Please update new user repository URL
git remote set-url origin https://[email protected]/repository.git
I tried using below commands, it's not working:
git config user.email "[email protected]"
git config user.name "user"
OR
git config --global user.email "[email protected]"
git config --global user.name "user"
Upvotes: 34
Reputation: 16595
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 https://{new url with username replaced}
to update the URL with your new username.
Upvotes: 244