Reputation: 163
I am trying to push some modifications into a git repository, but get the message: "I get the fatal: unable to access 'repository': The requested URL returned error: 403
Allow me to give you a few more details:
I work on Linux Ubuntu, 20.04.3 LTS
I use my PAT which I recently generated as a password. (I am pretty sure it is fine, because it doesn't give me the Authentication failed
error.
In my .bashrc
file, I have the following lines:
git config --global user.name "Niceno"
git config --global user.email "[email protected]"
which are both correct, and have been working for several years now.
.git/config
reads:[core]
repositoryformatversion = 0
filemode = true
bare = false
logallrefupdates = true
[remote "origin"]
url = https://github.com/DelNov/T-Flows
fetch = +refs/heads/*:refs/remotes/origin/*
[branch "development_branch"]
remote = origin
merge = refs/heads/development_branch
which doesn't tell me much.
5. If I log in in the Git account DelNov
, to which I have admin rights, I see that the user Niceno
, my humble me, is granted access to repository.
I am really baffled, because I am trying to do something which I was doing for years. Yet all of a sudden, I can't do a simple push.
Any advice would be appreciated.
Upvotes: 5
Views: 45111
Reputation: 137
all you need to do is remove the current repository URL using this
git remote remove origin
and after that Relink the git repository using this
git remote add origin https://github.com/UserName/repositoryName.git
Upvotes: -1
Reputation: 1
"I am trying to push some modifications into a git repository, but get the message: "I get the fatal: unable to access 'repository': The requested URL returned error: 403"
This has just happened to me too but upon checking properly I have realized that my token has no permission to push to my repo, if you are facing this issue check your token permission or delete your token and generate a new one with all access grant.
Upvotes: -1
Reputation: 444
Go to your local repository folder and find a hidden folder called ".git". find a file called "config" in the folder as attached below.
You need to change the url = https://github.com/... to SSH url that can find from GitHub repository(on git hub Web portal) cone menu as below picture.
This is what the config file looks like, after the change of the url.
This solved my issue. I believe this will help.
Upvotes: 1
Reputation: 445
I read your explanation and I hope this is what to did:
From the comments I understand that this is the first push of this project to the repository. So in this case it's advisable to set the full url https://username:[email protected]/username/repository.git --all instead of just doing git push origin --all.
I understand the fact that you were used to the git command lines but just in case you forgot some things this link will strongly help you as well
UPDATE:
I cloned and push the project base on the github url you provided in the comment. After doing this:
$ git remote add origin [email protected]:username/new_repo
Make sure you've clicked on the "copy" icon that is at right end of the repository's url from you github account to grab your real this ( [email protected]:username/new_repo ) without blank spaces added. Doing that I received a notification as the folder is empty ( Not a problem). Then I did:
$ git push -u origin master
And there came a fatal error, a rejection for push. But to force push I did:
$ git push -f origin
This gave a clue of the rejection it was about, then to force push the project and bypass the rejection I did this with my github account opened on browser on the same system:
$ git push --set-upstream origin main
And the push was successful. About the process to add an existing project to a new github repository take a look at this link
and take a look at the part that says "A new repo from an existing project" to make sure you started well. But if you do :
$ git push --set-upstream origin main
you should be able to get rid of the 403 rejection. But you might be connected to your github account on the system you're pushing with.
Upvotes: 1