1

I would like to change to another GitHub user. I removed the github.com Keychain entry and also tried to remove it via the command line (https://help.github.com/articles/updating-credentials-from-the-osx-keychain) but when I try to push commits using user2 the following error appears:

ERROR: Permission to user2/test-repo.git denied to user1.
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.

My .gitconfig contains this:

[credential]
  helper = osxkeychain

What can I do to remove the credentials from user1?

Andy
  • 841
  • 2
  • 8
  • 15

3 Answers3

1

Hey thanks for your answer. I cloned the repo using the new user, this works probably because it's a public repo but I can't push. The output from git remote -v is this:

origin  git@github.com:user2/test-repo.git (fetch)
origin  git@github.com:user2/test-repo.git (push)

I can't find out where my old username is saved ...

Andy
  • 841
  • 2
  • 8
  • 15
1

I just found the solution. It works when I clone the repo using HTTPS.

git clone https://github.com/user2/test-repo.git

When I try to push, I'm able to insert my new credentials and can push successful. YEHH!!!

Andy
  • 841
  • 2
  • 8
  • 15
0

What is the url of your repo in your .git/config file.

looks like you have cloned the repo using http/https so he user name and passwords are in your file.

Check youir remote settigns:

git remote -v

The url needs to be something like

ssh://git@.../repo.git; 

If the url doesn't start with ssh your ssh key are not used

To set up your ssh url you can either edit the config file or use command line.

git remote set-url origin ssh://git@ip:port/repo.git
CodeWizard
  • 128,036
  • 21
  • 144
  • 167