9

I had an account on github (Mariogs37) that I've since stopped using. In the meantime, I've created a new one (bclayman) that I'd like to start using. I created a repo on github and ran:

git remote add origin https://github.com/bclayman/SquashScraper.git

I get no error messages, and then I run:

git push -u origin master

However, I get this error message:

remote: Permission to bclayman/SquashScraper.git denied to Mariogs37.
fatal: unable to access 'https://github.com/bclayman/SquashScraper.git/': The requested URL returned error: 403

I googled around for similar issues and came across this link:

http://stackoverflow.com/questions/24019258/git-thinks-im-the-wrong-user

I followed vonC's answer's instructions (here: https://help.github.com/articles/generating-ssh-keys/#step-3-add-your-ssh-key-to-github). At the end of adding my SSH key to github, I got this in my terminal:

Hi bclayman! You've successfully authenticated, but GitHub does not provide shell access.

I retried pushing my local repo to github but have run into the same error. Any idea why it still thinks I'm Mariogs37 (and thus don't have permissions to push to a repo on github owned by bclayman)?

Thanks,

bclayman

anon_swe
  • 8,791
  • 24
  • 85
  • 145
  • Did you update your `.gitconfig`? also check this out: http://superuser.com/questions/232373/how-to-tell-git-which-private-key-to-use – Jörn Hees Jun 03 '15 at 17:19
  • What would I update it with? In my gitconfig, I have my email and name set up and credential has "helper = osxkeychain" – anon_swe Jun 03 '15 at 17:22
  • oh, just seen you're using the https URI... the above would work for the ssh one, but for changing the https user you probably want to read this: http://stackoverflow.com/a/14417827/1423333 – Jörn Hees Jun 03 '15 at 17:26
  • ah, if you're using osxkeychain it probably saved the https credentials (username and password) in your keychain, so could try to delete them there. – Jörn Hees Jun 03 '15 at 17:30

2 Answers2

9

This most likely is a misunderstanding in what credentials are used for what.

GitHub offers you to use two different protocols to access your repo:

  • HTTPS
  • SSH

SSH:

This one uses the ssh keys and settings in your ~/.ssh folder. It is used if you add a remote like this:

git remote add origin git@github.com:bclayman/SquashScraper.git

HTTPS (the one you chose):

This one uses the https credentials that depending on your system could be stored in various places (if at all). As it seems you're using the OS X Keychain, so they are most likely stored there. The https protocol is used if you add a remote like this:

git remote add origin https://github.com/bclayman/SquashScraper.git

So to get this resolved i'd open your OS X Keychain and search for https://github.com and delete all items that come up. Next time you try to push / fetch it should ask you for your username and password again.

Jörn Hees
  • 3,338
  • 22
  • 44
  • Thank you! I've had a persistent issue with [gitbox](http://www.gitboxapp.com/) and old repos/changed usernames. Clearing those from the keychain was the fix for me. – SimplGy Sep 16 '15 at 14:04
1

Did you try below?

git config --global user.name "bclayman"
git config --global user.email "email_addr_of_bclayman"

And also make sure under your ~/.ssh folder, no ssh key related to Mariogs37, if any, delete them. Only keep ssh key of bclayman.

mainframer
  • 20,411
  • 12
  • 49
  • 68