git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
* [credential.helper] unexpectedly save credential to multiple credential files
@ 2016-11-11  8:10 Qi Nark
  2016-11-11  8:36 ` Jeff King
  0 siblings, 1 reply; 3+ messages in thread
From: Qi Nark @ 2016-11-11  8:10 UTC (permalink / raw)
  To: git

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?

Thx.

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [credential.helper] unexpectedly save credential to multiple credential files
  2016-11-11  8:10 [credential.helper] unexpectedly save credential to multiple credential files Qi Nark
@ 2016-11-11  8:36 ` Jeff King
  2016-11-11  9:12   ` Qi Nark
  0 siblings, 1 reply; 3+ messages in thread
From: Jeff King @ 2016-11-11  8:36 UTC (permalink / raw)
  To: Qi Nark; +Cc: git

On Fri, Nov 11, 2016 at 04:10:55PM +0800, Qi Nark wrote:

> 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

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [credential.helper] unexpectedly save credential to multiple credential files
  2016-11-11  8:36 ` Jeff King
@ 2016-11-11  9:12   ` Qi Nark
  0 siblings, 0 replies; 3+ messages in thread
From: Qi Nark @ 2016-11-11  9:12 UTC (permalink / raw)
  To: Jeff King; +Cc: git

On Fri, Nov 11, 2016 at 4:36 PM, Jeff King <peff@peff.net> wrote:
> On Fri, Nov 11, 2016 at 04:10:55PM +0800, Qi Nark wrote:
>
>> 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


Ok, that's fair enough. Thanks for your detailed explanation. The
version info is very important to me.

Thank you again.

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2016-11-11  9:12 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-11-11  8:10 [credential.helper] unexpectedly save credential to multiple credential files Qi Nark
2016-11-11  8:36 ` Jeff King
2016-11-11  9:12   ` Qi Nark

Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).