How to solve the requested URL returned error: 403 in git repository
Asked Answered
W

14

47

I have multiple accounts in git I committed code three weeks back with this account. I'll unable to pull my code . I was getting The requested URL returned error: 403 I'll try Pushing to Git returning Error Code 403 fatal: HTTP request failed but I couldn't solved my error

git -c diff.mnemonicprefix=false -c core.quotepath=false fetch origin
remote: Forbidden
fatal: unable to access 
'https://[email protected]/chantidurgam/patanjali.git/': The requested 
URL returned error: 403

Completed with errors, see above.

Wismar answered 27/9, 2018 at 9:5 Comment(2)
Credential Manager?Acrobat
I have noticed that bitbucket sometimes takes up to 10 minutes before a newly added user to a repositiory can "pull", although it is already visible from the web interface. I'd advise anybody running into an unexpected 403 to give it some time before taking other steps.Bitten
M
38

What needs to be checked before anything else is the access level, which should be set to write. This can happen if you were added to the repo by someone else, and they forgot to grant you the required permissions.

enter image description here

Montespan answered 17/10, 2019 at 15:0 Comment(1)
thx @armin, I was struggling for an hour, even I have changed my password as sometimes it was saying that my password is wrong. +1 for saving my day.Ceil
F
18

I had the same issue when using the git cli and sourcetree - and doing the below solved it.

This is basically an auth issue and git had stored my creds for both bitbucket and github. All I had to do was delete those saved entries using sourcetree.

I am using SourceTree, so went to Tools -> Options -> Authentication

and under git saved passwords, I deleted them all.

This post can lead to other ways of doing the same as well.

Remove credentials from Git

Floyd answered 3/11, 2018 at 7:29 Comment(1)
Yup deleting all saved passwords in SourceTree worked for me! Thanks! Been struggling with this issue for nearly an hour now lolLelia
C
13

Hi guys I am getting Support for password authentication was removed on August 13, 2021. Please use a personal access token instead. remote: Please see https://github.blog/2020-12-15-token-authentication-requirements-for-git-operations/ for more information.

Problem solution step by step

Now we have need Token authentication requirements for Git operations becouse Github has made changes in password authentication for security purpose.

There are some you need follow to generate Personal access tokens.

direct link https://github.com/settings/tokens/new for create personal access token

Step 1 - Open GitHub and sign in with your credentials.

Step 2 - Click on the Setting menu.

Step 3 - In Setting menu you click on Developer Settings, there are two option avaialable for OAuth apps and Personal access tokens.

Step 4 - We need to click on Personal access token enter image description here

step 5 - click on the Generate new Token button.

enter image description here

enter image description here

Step 7 - After that generate new token. Copy that generated token and use this token to access git with username and token.

Now Manage your credentials in system

For window user

1.) Open Control Panel => User Accounts => Manage your credentials => Windows Credentials.

enter image description here

enter image description here

In password box paste your access token and click to save button and reference your desktop.

Now you can access git.

If you are access git in android studio, if ask for a password then add GitHub Personal access token instead of your password.

And if you want use android terminal then paste cammand in terminal

 git push  https://[email protected]/username/yourrep.git
Capsule answered 15/8, 2021 at 4:36 Comment(0)
J
9

Here's how I solved mine.

  1. Go to bitbucket and open the repository.
  2. At the top right corner is a "clone button" Bitbucket clone button

  3. Click the button and copy the url. It will look something like this: git clone https://[email protected]/something/something.git

  4. Open your terminal for and type the following

git remote remove origin
git remote add origin https://[email protected]/something/something.git

Then just do git push. Note: Git may prompt you to do this.

git push --set-upstream origin master

Do it. I did and mine works now.

Janicejanicki answered 1/12, 2019 at 1:4 Comment(0)
S
9
git config --global --unset credential.helper

The above code worked for me. As @Kunal said, I think a reason I had this issue was as a result of saving my credentials a while back and this causing an auth issue now. I hope the code works, this stumped me for over an hour.

Shawanda answered 27/4, 2020 at 8:38 Comment(0)
C
6

Reset the git credentials: If its ubuntu system:

Unset the username and password

git config --global --unset credential.helper
git config --unset credential.helper

Open the .git-crendentials and remove existing username and password

vim ~/.git-credentials

https://username:[email protected] to https://mygit.github.com

Store git credentials again:

git config --global credential.helper store
git pull

If it is windows:

Go to Control Panel\User Accounts\Credential Manager In under Generic Credentials, You can see the stored git passwords and remove it. enter image description here

Cellophane answered 9/10, 2020 at 10:30 Comment(1)
Well explained!Lagting
A
3

I have tried all the above solutions but non of them worked for me. My repo. using a proxy setting that I haven't added, Later I found that and added like :

git config http.proxy http://example.com

And its started work for me.

Araucanian answered 2/2, 2022 at 15:38 Comment(0)
F
2
  1. Delete last directory all of details or delete directory and create another.

  2. Go to ControlPanel < User Accounts < Credential Manager < Windows Credential(Generic Credentials) remove github/gitlab credentials

  3. run command git config --global <Url> http://localhost:<remote vpn port>

It's resolved

Frymire answered 1/1, 2023 at 15:7 Comment(0)
C
1

Hi if you have problem when you want to push your project in your git hub account and final error was 403-fatal-http-request-failed you sign in another account in your PC you must deleted that for this you must follow this address: ⇒ Control Panel\User Accounts\Credential Manager and remove past account in github this address is useful for Windows system

Chiapas answered 30/9, 2020 at 6:22 Comment(0)
R
1

For me this turned out to be a problem with 2-factor authentication between my Linux client and the Bitbucket website. When I went to do a pull from my server I got asked for my User:Pass and upon entering that correctly it gave me a The requested URL returned error: 403. I removed the 2-factor from Bitbucket and everything started working again.

Razorback answered 6/5, 2021 at 2:16 Comment(0)
U
0

For my case, this sourcetree specific issue is fixed by changing the ssh client as OpenSSH as I was having the key at C:\Users\username\ .ssh\id_rsa

You can change it at Tools -> Options -> General tab -> SSH client configuration

Note: For Putty or Plink, the key should be at C:\Users\username\ .ssh\id_rsa.ppk

Unipolar answered 31/8, 2020 at 13:12 Comment(0)
S
0

First try:

  1. delete any existing ssh key (/.ssh/id_rsa).
  2. ssh-keygen -t rsa -b 4096 -C "[email protected]" #generation of new ssh key Email github wali.
  3. after ssh key generation.
  4. eval $(ssh-agent -s) To start ssh agent
  5. ssh-add ~/.ssh/id_rsa
  6. clip < ~/.ssh/id_rsa.pub paste this into the ssh key section of github. Now pushing git

git init git add . git commit -m "" git status To check for the files. git remote add origin "url of the repo" This step only for the first time. git push -u origin master This is used for the initial push. Otherwise use git push. If still not working---- go to credential manager then windows credential and delete personel access token of github.

Sixtieth answered 2/9, 2020 at 7:33 Comment(0)
S
0

In your Bitbucket.org account, go into Repository menu > User and group access and change the permissions of your user to WRITE or ADMIN. Then try again in your git!

Shame answered 3/5, 2021 at 4:34 Comment(0)
L
-1

I have resolved this issues in Bitbucket by add an app password from here

Liqueur answered 23/11, 2021 at 12:41 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.