代码之家  ›  专栏  ›  技术社区  ›  millimoose Tomasz Nurkiewicz

有没有办法让Git记住WebDAV遥控器的密码?

  •  58
  • millimoose Tomasz Nurkiewicz  · 技术社区  · 14 年前

    我正在与Git合作,将更改推送到通过HTTP/WebDAV共享的存储库中,并且Git会为每个访问HTTP远程的操作提示输入密码。有没有办法让Git缓存密码/让远程服务器不提示我?

    远程Web服务器应该是Apache,如果需要,可以重新配置。

    3 回复  |  直到 9 年前
        1
  •  59
  •   millimoose Tomasz Nurkiewicz    9 年前

    方法是使用~/.netrc,如第3步所述 this Git documentation :

    然后,将以下内容添加到您的$home/.netrc中(您可以不使用,但将使用 要求输入密码a 许多 时代:

    machine <servername>
    login <username>
    password <password>
    

    …并设置权限:

    chmod 600 ~/.netrc
    

    更新:

    从Git1.7.9开始,看起来应该是本机凭证帮助器API。Git附带纯文本 credential store 或者一个不太方便但更安全的临时 credential cache . 也可以使用第三方凭证帮助程序。到目前为止,我知道 a helper for the native Windows Credential Store one that integrates with the OS X keychain .(与其他OS X Git发行版一样,自制的Git版本有一个二进制文件。Github还提供 standalone binary )

    一般来说,只需设置一次凭证助手就足够了:

    git config --global credential.helper wincred
    

    或者代替 wincred ,使用适合您平台的助手。(如果帮助程序可执行文件的名称为 git-credential-wincred ,设置选项的值将为 瓦辛德 等)

    凭证帮助器还支持在同一主机上为不同的存储库提供单独的凭证集。

        2
  •  25
  •   Kshitiz Sharma    10 年前

    在回购中运行此命令:

    git config credential.helper store
    

    然后向服务器推一次:

    git push
    

    用于推送到服务器的凭据将保存在 ~/.git-credentials .

    本指南中的说明 here .

        3
  •  16
  •   Oleg    12 年前

    为什么不能在远程URL中使用密码?

    $ git config remote.origin.url = http://username:password@origin_link.com/repository.git