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

由网友(遗忘。Forgotten)分享简介:我正在使用 Git 将更改推送到通过 HTTP/WebDAV 共享的存储库,并且 Git 会提示为访问 HTTP 远程的每个操作输入密码.有没有办法让Git缓存密码/远程服务器不提示我?I'm working with Git pushing changes to a repository shared over H...

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

I'm working with Git pushing changes to a repository shared over HTTP / WebDAV, and Git prompts for a password for every operation that accesses the HTTP remote. Is there any way to make Git cache the password / have the remote server not prompt me?

远程网络服务器应该是 Apache 并且可以在必要时重新配置.

The remote webserver should be an Apache and could possibly be reconfigured if necessary.

推荐答案

方法是使用~/.netrc,如这个 Git 文档:

The way is to use ~/.netrc as outlined in step 3 of this Git documentation:

然后,将以下内容添加到您的 $HOME/.netrc 中(您可以不添加,但将要求输入您的密码很多次):

Then, add the following to your $HOME/.netrc (you can do without, but will be asked to input your password a lot of times):

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

...并设置权限:

chmod 600 ~/.netrc

更新:

从 git 1.7.9 开始,似乎要走的路是原生凭证助手 API.Git 带有一个纯文本 凭证存储 或更不方便但更安全的临时 凭证缓存.也可以使用第三方凭证助手.到目前为止,我知道 本机 Windows Credential Store 的助手,以及 一个与 OS X 钥匙串集成的.(Homebrew 提供的 Git 版本有一个二进制文件,其他 OS X Git 发行版也有.Github 还提供了一个 独立二进制文件.)

UPDATE:

解决方法 git提交远程,每次都要输入用户名和密码

As of git 1.7.9, it seems the way to go would be the native credential helper API. Git comes with a plaintext credential store or a less convenient but more secure temporary credential cache. It's also possible to use third-party credential helpers. So far I'm aware of a helper for the native Windows Credential Store, and one that integrates with the OS X keychain. (The Git build shipped by Homebrew has a binary for it, as might other OS X Git distributions. Github also provides a standalone binary.)

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

Generally, it should be sufficient to set up the a credential helper once:

git config --global credential.helper wincred

或者代替 wincred,使用适合您平台的任何帮助程序.(如果 helper 可执行文件的名称是 git-credential-wincred,则您设置的选项值将是 wincred 等)

Or instead of wincred, use whichever helper is appropriate for your platform. (If the name of the helper executable is git-credential-wincred, the value you set the option to will be wincred, etc.)

凭证助手还支持为同一主机上的不同存储库拥有单独的凭证集的需要.

The credential helpers also support the need to have separate sets of credentials for different repositories on the same host.

阅读全文

相关推荐

最新文章