55

My git was working fine, then without changing anything than the following problem started to happen, I have tried resetting the cache in

credentials.helper

and have gone through pretty much every stackoverflow answer I could find

remote: Password authentication is not available for Git operations.
remote: You must use a personal access token or SSH key.
remote: See https://github.ibm.com/settings/tokens or
'https://github.ibm.com/WBurney/Blockchain_SDO.git/': 
The requested URL returned error: 403

Thanks

osowskit
  • 5,904
  • 2
  • 29
  • 38
  • `I have tried resetting the cache` ... what did you actually do? You may have read many answers but we don't know what you did to get to this state. – Tim Biegeleisen Aug 27 '17 at 08:34

9 Answers9

58

If you have registered a public ssh key to your GitHub enterprise account, you could side-step the issue using an ssh url

cd /path/to/repo
git remote set-url origin git@github.ibm.com:WBurney/Blockchain_SDO.git

Then any command like git push/git fetch/git pull/git ls-remote would use the SSH URL set by git remote set-url.

But regarding your original issue, try and follow "Creating a personal access token for the command line".

If you are on Mac, update your credentials from the OSX Keychain.

You might need to remove an old cached credential first.
(As commented by RayLoveless)

VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • I followed the following steps to add my ssh keys to git https://git.ng.bluemix.net/help/ssh/README.md Then i set the remote URL using git remote set-url origin git@github.ibm.com:WBurney/Blockchain_SDO.git Thanks for help – Muhammad Raafay Khan Aug 28 '17 at 08:21
  • @MuhammadRaafayKhan What is your OS and git version? – VonC Aug 28 '17 at 08:22
  • Ubuntu 17.04 and git version 2.11.0 – Muhammad Raafay Khan Aug 28 '17 at 08:24
  • You may have to clear your credentials cache so you get prompted to enter your password/token: https://stackoverflow.com/questions/15381198/remove-credentials-from-git – RayLoveless Apr 14 '20 at 21:04
  • 1
    @RayLoveless True: "erase" command on Mac or "reject" on Windows: https://stackoverflow.com/a/59890860/6309 – VonC Apr 15 '20 at 05:10
  • Worked for me using ssh . What if I want to do using http ? – NoobCoder Aug 21 '20 at 06:02
  • @NoobCoder First, that would be HTTPS, not HTTP. Second, as mentioned in the answer, the best practice would be to use a PAT (Personal Access Token) as a password (and your GitHub user account name as a login) – VonC Aug 21 '20 at 06:06
  • The Mac one worked for me. I was trying to clone a repo from IntelliJ and this error was coming up. Deleted the IntelliJ github entry in Keychain. Then tried to clone the repo and logged in with access token. It worked fine. Thanks – Ganesh Sep 24 '20 at 14:47
  • git push is not needed. – tedyyu Feb 22 '21 at 05:53
  • @tedyyu You are correct. I have edited the answer to make that clearer. – VonC Feb 22 '21 at 07:56
  • Updating credentials in key chain worked for me. – bosari Jul 29 '22 at 05:21
45

Another solution that worked for me was changing the credentials via the Windows Credentials Manager:

1) Clear your cached credentials (thanks @Rayloveless).

2) Follow the steps in this link to create an access token.

  • In the upper-right corner of any page, click your profile photo.
  • Click Settings
  • In the left sidebar, click Developer settings
  • Personal access tokens
  • Generate new Token

3) Go to "Windows Credential Manager" and look for your Github Enterprise account.

4) Click modify and replace the password with the token you generated.

Omar YAYA
  • 664
  • 6
  • 7
16

Try below one -

git clone https://<user-name>:<git-token>@<github-path.git>
Ajay Kumar
  • 4,864
  • 1
  • 41
  • 44
11

You need to reset the credential. Open GIT CMD and type below command

git credential reject

press enter. The cursor would be waiting for the next input. Then type

protocol=https
host=git.example.com

Replace git.example.com, with your link.

Press "enter" twice so let git know that's the end of the command. Now you need two things before any git operations as it will first validate your username and password.

  1. Username - It would present near your logo under signed in as. Example this is mine. Give the exact username -

enter image description here

  1. Password -
  • Click Settings
  • In the left sidebar, click Developer settings
  • Personal access tokens
  • Generate new Token (copy this token somewhere. It won't show up again)

Next, go to git cmd and do your git operation. for example -

git clone https://consulting-github.com/Rohan-Chikorde/example.git

Once started, it will prompt for username and password. Give the username example: Rohan-Chikorde and password: e67682yourgeneratedtoken as described above and you would be good to go.

rohan chikorde
  • 456
  • 5
  • 6
10

The accepted answer will work only for ssh, not for https.

The cache reset commends seems to have recently changed. For me that eventually made it work.

git credential reject
protocol=https
host=github.<YOUR_COMP>.com
Atul Soman
  • 4,612
  • 4
  • 30
  • 45
3

for me it was an easy process to go as

  1. generate my token
  2. git remote remove origin
  3. git remote add origin https://<token>@<git_url>.git
  4. now try the command(push,pull,..) again.
Ali Aref
  • 1,893
  • 12
  • 31
0

For me it worked when I deleted the old generated token and generated new one and used that

Monalisa Das
  • 667
  • 5
  • 3
0

First you should try to generate Personal Access Token(PAT) and then put it in Credential Manager as a password to your GitHub. For that: Go to Credentials Manager > Windows Credentials > GitHub(Under generic credentials). Now put your PAT as a password.

If you are still not able to clone the repo then try the method given in one of the answers here by Ajay, it worked for me once: git clone https://<user-name>:<git-token>@<github-path.git>

-5
git remote set-url origin git@github.ibm.com:WBurney/Blockchain_SDO.git

The above git command will works

Machavity
  • 30,841
  • 27
  • 92
  • 100