Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Git keeps mentioning my old username even if I can't find a trace of it

Tags:

git

github

remote: Permission to MYUSERNAME/project.git denied to OLD-USER-NAME

I have 2 GitHub users. One for personal use and one for work use. MYUSERNAME will be my personal one for this example and OLD-USER-NAME the work one. I've stopped using OLD-USER-NAME a while ago but I'm getting the above error when trying to push to a github https. I solved the problem by pushing directly to https://[email protected]...

I'm trying to figure out why my OLD-USER-NAME was even mentioned and how git "knows about it".

Things I've tried:

  1. ssh-add -l -> The agent has no identities.
  2. I couldn't find any .ssh folder.
  3. I don't have any ssh keys on both of my github accounts
  4. git config --global --edit or git config --edit shows MYUSERNAME
  5. git remote --verbose which gave me: origin https://github.com/MYUSERNAME/project.git (fetch) origin https://github.com/MYUSERNAME/project.git (push)
  6. OLD-USER-NAME GitHub -> Settings -> Security History I can see my ip with a green dot next to it. Maybe it got something to do with it?
like image 889
Segev Avatar asked Dec 24 '13 22:12

Segev


2 Answers

In addition to everything mentioned in the question and @gturri suggestions in the comments, the next step is to check whether git or the os are caching your credentials.

Check the keyring on your OSX / Linux / cygwin and also check if git config [--global] credential.helper has been set.

like image 184
mockinterface Avatar answered Oct 26 '22 18:10

mockinterface


you should check your remote:

git remote --verbose

If it says

origin  [email protected]:OLD-USER-NAME/project.git (fetch)
origin  [email protected]:OLD-USER-NAME/project.git (push)

then your can fix it doing

git remote set-url origin [email protected]:MYUSERNAME/project.git
like image 7
gturri Avatar answered Oct 26 '22 20:10

gturri