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

Re: [credential.helper] unexpectedly save credential to multiple credential files

From
Jeff King <peff@peff.net>
Date
Nov 11, 2016, 08:36 UTC
Message-ID
<20161111083649.d5newszupwyq5j6w@sigill.intra.peff.net>
In-Reply-To
<CACNr1V_fRfqvHUN=AQC8-Dj7ZAE7KXRAt+5skL3ZrcKu7SCLgA@mail.gmail.com>
On Fri, Nov 11, 2016 at 04:10:55PM +0800, Qi Nark wrote:
Show 9 quoted lines
> 1. git config --global credential.helper store
> 2. cd to a local repository directory, git config credential.helper
> store --file ./my_cred
> 3. execute some git command which need credential like git ls-remote
> 4. input my username & password, command done.
> 
> As the result, **BOTH** the ./my_cred and ~/.git-credentials will save
> the credentials I just input. But, shouldn't the local config override
> the global ones, and only the ./my_cred should save it?

No, that's the expected result. The set of credential helpers form a list, and each is run in turn. From "git help credentials":

  If there are multiple instances of the credential.helper configuration
  variable, each helper will be tried in turn, and may provide a
  username, password, or nothing. Once Git has acquired both a username
  and a password, no more helpers will be tried.

That's talking about lookup, but the same principle applies to storage. But you may also find the paragraph below helpful:

  If credential.helper is configured to the empty string, this resets
  the helper list to empty (so you may override a helper set by a
  lower-priority config file by configuring the empty-string helper,
  followed by whatever set of helpers you would like).

Note that the "reset" behavior was introduced in git v2.9.0, so you'll need at least that version.

-Peff
Previous: Qi NarkNext: Qi Nark
Message 2 of 3 in “[credential.helper] unexpectedly save credential to multiple credential files”
  1. Qi NarkNov 11, 2016
  2. Jeff KingNov 11, 2016
  3. Qi NarkNov 11, 2016

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.