有没有办法让 git 记住 WebDAV 遥控器的密码? [英] Is there a way to make git remember the password for WebDAV remotes?
问题描述
我正在使用 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 带有一个纯文本 凭证存储 或更不方便但更安全的临时
UPDATE:
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.
这篇关于有没有办法让 git 记住 WebDAV 遥控器的密码?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!