Home > Back-end >  git: Permission denied to git profile and The requested URL returned error: 403
git: Permission denied to git profile and The requested URL returned error: 403

Time:10-18

After cloning my git repository with the Personal Access Token:

git clone https://<Token>@github.com/<username>/<repo-name>.git

Then I made changes to my repository from my local pc and when I try pushing it I keep on getting the below error:

remote: Permission to Gtindi/alx-low_level_programming.git denied to Gtindi.
fatal: unable to access 'https://github.com/Gtindi/alx-low_level_programming.git/': The requested URL returned error: 403

I tried solving it with various solutions like navigating to .git/confug and changing my url from https://@github.com// to ssh://git@github// but I'm still getting the same error.

I even tried:

git config user.name "new name"
git config credential.username "new name"

But no change was made, still the same error. How can I solve it? I'm using Linux and running the git commands on linux terminal.

CodePudding user response:

You are successfully authenticating to GitHub as user Gtindi:

remote: Permission to Gtindi/alx-low_level_programming.git denied to Gtindi.

The word "remote" here means that this message is not from your Git software at all, but rather from some other software (in this case the permissions-checking software over on GitHub, which is the software that determines who you claim to be, whether you were able to prove that you are you who claim to be, and whether that person has permission to do whatever it is you're trying to do).

The remainder of the message shows that GitHub believe you are in fact Gtindi, but that Gtindi is not allowed to push to Gtindi/alx-low_level_programming.git.

This implies that what you need to do is log in to GitHub and give yourself permission to write to your own repository.

When using https to authenticate to GitHub, the token you send is essentially a fancy encoded password that includes permissions controls. You must set up the token to have push permission. When using ssh to authenticate to GitHub, the permissions are simpler.

In no case is user.name ever used for authentication. Whether credential.username is ever used will depend on the credential helpers you have selected, but you're probably using the "cache" or "store" helper, which would not use that.

  • Related