我如何获得git要求我输入密码

时间:2018-09-19 13:05:19

标签: git credentials

所以我有git设置来将我的凭据缓存5分钟。...这一切都很好,但这只能解决部分问题...

所以我有一个脚本可以执行以下操作:

audio

所以目前我正坐在屁股上等待2分钟,等待git要求我输入密码……

我真正想要的是在git中触发一些命令,这将迫使git询问我密码并为脚本的长度缓存我的凭据……这是可能的:

rmdir -rf repo1
rmdir -rf repo2  # These operations take ~2 minutes
rmdir -rf repo3

git clone path\to\repo1  # Only now does it ask me for my password
git clone path\to\repo2
git clone path\to\repo3

# build it

1 个答案:

答案 0 :(得分:-1)

这可以使用git-credential-cache完成。

  

此命令将凭据缓存在内存中,以供将来的Git程序使用。存储的凭据永远不会接触磁盘,并且在可配置的超时后会被忘记。可以通过Unix域套接字访问该缓存,该缓存受文件系统权限限制为当前用户。

该命令可以如下使用:
$ git config credential.helper 'cache [<options>]


例如,如果您想在五分钟后使凭据失效,则可以通过credential.helper配置变量提供选项:

$ git config credential.helper 'cache --timeout=300'


在此处了解更多信息:
https://git-scm.com/docs/git-credential-cache