1

I forked a GitHub repository from my friend’s account, but when I try to push my commits, I get this error:

remote: Permission to Fatima-Ennouari/test.git denied to Ridafadli. fatal: unable to access 'https://github.com/Fatima-Ennouari/test.git/': The requested URL returned error: 403

Here’s what I did:

  1. I forked the repo from Fatima-Ennouari/test.

  2. I cloned my fork locally:

git clone https://github.com/Ridafadli/test.git
  1. I made some changes and committed them.

  2. Then I ran:

git push origin main

But got the 403 error above.

I’m logged into my GitHub account (myname), and I can see my fork on my profile.

1
  • Why do you tag this with "gitlab" when there is literally zero relation to it in your question? Commented Nov 16 at 20:36

2 Answers 2

4

Apparently you have cloned locally upstream repository (the original repository that you've forked).

In this case origin points to the upstream repository and you just don't have permissions to update it.

Type in the terminal

git remote -v

And check what repository the origin alias is pointed to.

You should clone locally the forked repository that is located in YOUR github profile, not the upstream repository.

Sign up to request clarification or add additional context in comments.

2 Comments

The last sentence makes it sound like it is an error cloning from the upstream when it is not. I think it is worth explaining to fork the upstream into a repo of the OP's on the provider and set ip up as a second remote of the local.
This sentence is related to the context of the question. OP wants to make changes to the cloned repo and save the changes to the remote.
1

Your URL is

https://github.com/Ridafadli/test.git

and you ran

git push origin main

and received a permission error referring to

Fatima-Ennouari/test.git

and the error message also successfully identified the issuer as Ridafadli, so it's not an authentication issue nor a network issue, but actual permission issue. Let's take another careful look at the error message:

remote: Permission to Fatima-Ennouari/test.git denied to Ridafadli. fatal: unable to access 'https://github.com/Fatima-Ennouari/test.git/': The requested URL returned error: 403

Since you wanted to push to origin and origin was identified as Fatima-Ennouari/test.git, this means that origin is not what you think.

You can list the remotes via

git remote -v

and see what origin points to. You either have another remote pointing to the place you wish, or no other remote. You can change your origin as

git remote set-url origin <desired_path>

but and then add a remote for the repo you forked so that you can pull, like

git remote add "fatima" <the_other_path>

and then whenever you pull from there you can run

git push fatima <yourbranch>

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.