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
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':
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.
Firstly you need to change credentials from your local machine
git config [--global] user.name "Your Name"
git config [--global] user.email "email@address.com"
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 = xyz@xyz.com
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.
To set your account's default identity globally
run below commands
git config --global user.email "you@example.com"
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 "you@example.com"
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 = FirstName.LastName@company.com
[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.
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.