2

Problem faced:
I cannot git push to my repo, error message:

remote: Permission to fishercoder1534/Leetcode.git denied to MY_OLD_GITHUB_ACCOUNT
fatal: unable to access 'https://github.com/fishercoder1534/Leetcode.git/': 
The requested URL returned error: 403`

Research I have done:

  1. looking at this post, I have all these correctly pointing to my new github account: git config --global user.name "NewAccountFirstname NewAccountLastname" git config --global user.email "my_new_github_account_email@gmail.com"
  2. I have deleted my old ssh keys, generated new ssh keys, placed them under ~/.ssh/, also add them into my new Github account.
  3. I have created a ~/.ssh/config file with the following contents as suggested by the above post: Host github.com User git IdentityFile ~/.ssh/id_rsa # wherever your "new" key lives IdentitiesOnly yes
  4. I have run $ssh -vT git@github.com which all shows my new Github account info. Hi fishercoder1534! You've successfully authenticated, but GitHub does not provide shell access.
  5. I have run $ssh -i ~/.ssh/id_rsa -vT git@github.com, it's also showing my new Github info, with Hi fishercoder1534! You've successfully authenticated, but GitHub does not provide shell access.

What's next option to try/help?

Community
  • 1
  • 1
Fisher Coder
  • 3,278
  • 12
  • 49
  • 84

1 Answers1

2

An https url (https://github.com/fishercoder1534/Leetcode.git) means that every settings you have done for ssh doesn't matter.
And user.name/user.email have nothing to do with a Git repo server authentication.

Check if you have cached your https github.com credentials in a credential manager with git credential.helper:

git config credential.helper

That would explain why your old account keeps being used.
For osxkeychain, you can update your account

Or, of course, you can switch to an ssh url:

git remote set-url origin git@github.com:fishercoder1534/Leetcode.git
VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • That's right: `git config credential.helper`, it returns me `osxkeychain` – Fisher Coder Jan 15 '17 at 06:29
  • @fishercoder1534 I have added a link for you to update your https credentials. – VonC Jan 15 '17 at 06:31
  • @fishercoder1534 no problem: remember, https and ssh are two different protocols: https://git-scm.com/book/en/v2/Git-on-the-Server-The-Protocols#The-HTTP-Protocols vs. https://git-scm.com/book/en/v2/Git-on-the-Server-The-Protocols#The-SSH-Protocol – VonC Jan 15 '17 at 06:35