git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: Git credential helper store flushes randomly

From
РАРайцин Антон <anton@smarthead.ru>
Date
May 12, 2017, 10:05 UTC
Message-ID
<55d2b225-1f12-eb26-7333-131538b519fa@smarthead.ru>
In-Reply-To
<20170512084513.duj7sesylo7jdd3w@sigill.intra.peff.net>
12.05.2017 11:45, Jeff King пишет:
Show 20 quoted lines
> On Fri, May 12, 2017 at 10:24:50AM +0200, Matthieu Moy wrote:
>
>> Jeff King <peff@peff.net> writes:
>>
>>> The only time it should remove an entry is when Git asks it to. And the
>>> only time that happens is when Git sees the credential rejected by the
>>> server (e.g., an HTTP 401 even after we fed the stored credential). I
>>> don't know why that would happen unless there's some non-determinism on
>>> the server.
>> I did see a case like this where the server was broken temporarily and
>> rejected one login attempt. In this case the credential store deletes
>> the entry for that user, and when the server is repaired, the store
>> still has the entry deleted.
> Right, that's inconvenient if your server is flaky, but is the expected
> behavior. Git has to throw away the credential so it can stop trying it
> and actually prompt you on the next try (and save the result then if it
> works).
>
> -Peff
>

Thank you all! I've found the reason and successfully fixed the problem. Here is a description.

Most of repositories of this user were on one server EXAMPLE.COM. Some origins were configured like https://USER@EXAMPLE.COM. And they worked fine. Git just searched in ~/.git-credentials the "USER:password@EXAMPLE.COM" entry and everything was good. But some repositories' origins were configured without username, just https://EXAMPLE.COM. So git tried to find just a EXAMPLE.COM in the credentials store. Then git took the first entry and tried to connect to remote origin, got 401 unauthorized error and deleted first entry from helper store. The randomness was manifested due to the fact that git rotates the records in .git-credentials every time it connects to remote origin, it moves the right account string to the top of the file.

I think it will be good idea to add this information to https://git-scm.com/docs/git-credential-store, especially the info about deletion behavior, when git gets 401 error.

Best regards, Anton.

Previous: Jeff King
Message 5 of 5 in “Git credential helper store flushes randomly”
  1. Райцин АнтонMay 12, 2017
  2. Jeff KingMay 12, 2017
  3. Matthieu MoyMay 12, 2017
  4. Jeff KingMay 12, 2017
  5. Райцин АнтонMay 12, 2017

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.