简体   繁体   中英

Temporarily disable git credentials

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, ie, 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.

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM