Git credential helper causes “repository not found

2020-07-24 16:39发布

问题:

Just ran into this Git behavior which looks like a bug with credential-store:

$ git pull Username for 'https://github.com': ... Password for 'https://...@github.com': ... Already up-to-date. $ git config credential.helper store $ git pull remote: Repository not found.

Then, go and edit .git/config to remove [credential] helper = store and git pull works again.

What could cause it?

How do I use credential helper without running into this error?

UPDATE Using git version 1.9.1 on Ubuntu 14.04

UPDATE Retested with git version 2.9.3, same result.

UPDATE I have several accounts on github in ~/.git-credentials. I ran git with GIT_CURL_VERBOSE=1 GIT_TRACE=1 and it looks like it picks the first github account in the order they're listed.

However .git/config in the repo I'm working in has the correct user.email, which does have a matching entry in ~/.git-credentials. It just doesn't use that entry.

回答1:

What worked for me was in .git folder I opened the config file.

Now you need to insert:

[credential "https://github.com/yourProjectPath"]

username = yourGithubUsername

After this you can use:

git config credential.helper store

This will add this to the config file:

[credendial]
helper = store

Make sure the config file has this section at the end and does not have a duplicate of it before the "credential" section you added previously

Then run:

git pull

And fill in your password.



回答2:

If you are on Linux, the first thing to do is to update Git to its latest version through git-core/+archive/ubuntu/ppa.

sudo add-apt-repository ppa:git-core/ppa
sudo apt-get update

Then check if the issue persists with git 2.9.3.


Arun Wilson mentions in the comments:

In my case, there were two entries in ~/.git-credentials against github.com and first one was wrong against from the repo folder that I pulled

https://username-2:********@github.com    
https://username-1:********@github.com    
https://username-1:*********@gitlab.com   
https://username-1:*********@bitbucket.org


标签: git