Reputation: 4993
I have changed my user and email for git with those commands
git config --global user.name "maa"
git config user.email "[email protected]"
I confirmed the change with
git config --global user.name
git config user.email
and it shows the right names. However when I push the old user name is used:
git push -u origin master
remote: Permission to maa/brain.git denied to old_user_name.
fatal: unable to access 'https://github.com/maa/brain.git/': The requested URL returned error: 403
Upvotes: 2
Views: 19486
Reputation: 1422
Locally:
git config credential.username 'new_username'
Globally:
git config --global credential.username 'new_username'
Upvotes: 3
Reputation: 34003
The user.name
and user.email
settings are only used for commit meta data.
As I can see you are using https transport, so the username is stored somehow. To my mind there are two options:
%HOME%/.netrc
(%HOME%/_netrc
or %HOMEDRIVE%%HOMEPATH%\_netrc
on Windows)https://[email protected]/...
), here you need to update .git/config
, e.g. by issuing git remote set-url https://<newusername>@github.com/<newusername>/yourRepo
As a general rule you can try the following on the CLI (based on 2), where you replace $credentialhelper
with your credential-helper (you can find it using git config credential.helper
, for Mac OS X it is likely osxkeychain
on Windows it might be wincred
or manager
):
$ git credential-$credentialhelper erase
host=github.com
protocol=https
[Press Return]
Upvotes: 7