7

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.

Eric
  • 95,302
  • 53
  • 242
  • 374
Alex I
  • 19,689
  • 9
  • 86
  • 158
  • My guess is that you entered bad credentials. – Tim Biegeleisen Aug 31 '16 at 01:36
  • 1
    @TimBiegeleisen: I *didn't* enter credentials! It never asked me, after credential helper was set. – Alex I Aug 31 '16 at 02:41
  • What I meant by the comment was that the credentials which you stored have a problem. – Tim Biegeleisen Aug 31 '16 at 02:41
  • @TimBiegeleisen: Okay. Where did it get the credentials from, and where did it store them? (notice that the credential helper is enabled only after the login, not before) Why does it say "repository not found", rather than something like "incorrect username or password"? – Alex I Aug 31 '16 at 06:02
  • "Repository not found" is just what it fails on. Technically, it makes sense because it could not authenticate you and therefore could not find any repos. – Tim Biegeleisen Aug 31 '16 at 06:11

2 Answers2

15

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.

Fito
  • 478
  • 4
  • 10
ThomasCarlsen
  • 151
  • 1
  • 5
1

If you are on Ubuntu 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
Nick Cox
  • 6,164
  • 2
  • 24
  • 30
VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • @AlexI OK, I have rewritten the answer. – VonC Aug 31 '16 at 09:20
  • Upgraded to 2.9.3, results are identical – Alex I Sep 08 '16 at 21:25
  • I have several accounts at github. They are all in ~/.git-credentials. I ran git with GIT_CURL_VERBOSE=1 GIT_TRACE=1 and it looks like it picks the *first* github account from ~/.git-credentials. However .git/config in the repo I'm working in has the correct user.email, which does have a matching entry in ~/.git-credentials. Bug? – Alex I Sep 08 '16 at 21:28
  • 1
    @AlexI I'm struggling with the same stupid behaviour. I'd call it a bug because both the error message and it ignoring the right email is bad UX and wrong. – Avamander Apr 04 '18 at 19:46
  • @VonC I'm using 2.15.1 – Avamander Apr 04 '18 at 20:10
  • @Avamander Does the issue persists with Git 2.17? Are you on Ubuntu? – VonC Apr 04 '18 at 20:12
  • @VonC I installed git 2.16.2 from the PPA, the issue still persists. I'm on Ubuntu 18.04. – Avamander Apr 04 '18 at 20:30
  • @Avamander And what is the value of `git config credential.helper`? – VonC Apr 04 '18 at 20:32
  • @VonC The output is `store`. – Avamander Apr 04 '18 at 20:33
  • @Avamander Could you try using libsecret? (as in https://stackoverflow.com/a/42285250/6309) – VonC Apr 04 '18 at 20:34
  • @VonC This is the output after setting the `credential.helper` to `libsecret`: `git: 'credential-libsecret' is not a git command. See 'git --help'. Username for 'https://github.com': ^C` – Avamander Apr 04 '18 at 20:38
  • @Ava It is in the contrib folder of Git: add it to your PATH – VonC Apr 04 '18 at 20:40
  • @VonC I guess it works, but I don't want to start unlocking my keyring either. The whole point of `store` was that I don't have to enter anything on my own PC. – Avamander Apr 04 '18 at 20:51
  • 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``` – Arun Wilson Jul 19 '20 at 07:20
  • @ArunWilson Thank you for the feedback. I have included your comment in the answer for more visibility. – VonC Jul 19 '20 at 11:45