0

I have a problem with git. I have 2 users for different projects. Now when I am trying to push request, I get that

remote: Permission to secondUser/project2.git denied to firstUser.

The requested URL returned error: 403

As I understand I need to change username. After change username, I get the same error. Any idea

Vahe Akhsakhalyan
  • 1,495
  • 2
  • 19
  • 32

2 Answers2

0

This is a user rights issue.

If you have cloned your repository using SSH git clone git@github.com:... this is a SSH key issue. On GitHub users are authenticated by SSH keys, the SSH keys cannot be shared between two users. So switch your keys before to run git push in order to push as secondUser.

You could try to clone your repository using HTTPS git clone https://github.com/.... Then you will be able to push with the wanted user (It will ask you to enter your credentials).

Finally, you can also add the firstUser as a collaborators on the secondUser/project2 (Settings > Collaborators).

jmlemetayer
  • 4,334
  • 1
  • 28
  • 42
-2

Listed Method 2 from jml:

Change Git remote url to https:

git remote set-url origin https://USERNAME@github.com/USERNAME/PROJECTNAME.git


git push

To ensure that the commits appear as performed by USERNAME, one can setup the user.name and user.email for this project, too:

git config user.name USERNAME
git config user.email USERNAME@example.com
Edward Chan JW
  • 202
  • 3
  • 7