代码之家  ›  专栏  ›  技术社区  ›  DarthRubik

如何让git询问我的密码

  •  -1
  • DarthRubik  · 技术社区  · 6 年前

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

    所以我有一个脚本,它是这样做的:

    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
    

    所以现在我坐在床上等了2分钟,等待git让我输入密码。。。。。。

    我真正想要的是在git中触发一些命令,强制git询问我的密码并缓存脚本长度的凭据。。。。。。这是否可能:

    git ask_me_my_password domain
    
    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 回复  |  直到 6 年前
        1
  •  -1
  •   Trent    6 年前

    可以使用 git-credential-cache

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

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


    例如,如果要在五分钟后使凭据无效,可以通过凭据提供选项。助手配置变量:

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


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

    推荐文章