Home > Software design >  Temporarily disable git credentials
Temporarily disable git credentials

Time:01-27

I'd like to test some commands that shall eventually be used for CI automatization. They involve cloning a private repository to which I have acces via my stored git credentials. To see if the commands work for my purpose (they involve the use of a deploy key), I'd like to simulate a situation in which I have no access via my stored git credentials.

Any idea how to easily achieve that, i.e., how to disable the credentials temporarily? Or how to quickly create an environment from which the stored credentials are not used?

In case that is of importance: git config credential.helper returns manager-core for me.

CodePudding user response:

Since your credentials are stored in a credential helper, you can reset the credential helper list to empty by setting credential.helper to the empty string. For an arbitrary command, you can do that by placing -c credential.helper= between git and the command name.

For example, for a clone of the Git project's repository, you could do this:

$ git -c credential.helper= clone https://github.com/git/git.git
  • Related