我在代理后面。要使 git
正常工作,我必须添加
proxy = http://username:password@proxy.at.your.org:8080
到 .gitconfig
。
因为 username
和 password
是我的系统凭据,所以这个解决方案很糟糕,因为我必须将它们存储为 cleartext
。
我使用的是 Google Chrome
,我不需要设置任何代理设置,因为它使用系统代理设置。
如何使用 git
做到这一点?
最佳答案
2016 年 2 月更新:
使用 git 2.8(2016 年 3 月),您不必在 url 中以明文形式嵌入您的密码。
参见 commit 372370f , commit ef97639 (2016 年 1 月 26 日)作者:Knut Franke (``) .
帮助:Junio C Hamano ( gitster
) , Eric Sunshine ( sunshinebell28
) , 和 Elia Pinto ( devzero2000
) .
(由 Junio C Hamano -- gitster
-- merge 于 commit 30f302f ,2016 年 2 月 3 日)
http
: use credential API to handle proxy authenticationCurrently, the only way to pass proxy credentials to curl is by including them in the proxy URL. Usually, this means they will end up on disk unencrypted, one way or another (by inclusion in
~/.gitconfig
, shell profile or history).
Since proxy authentication often uses a domain user, credentials can be security sensitive; therefore, a safer way of passing credentials is desirable.If the configured proxy contains a username but not a password, query the credential API for one. Also, make sure we approve/reject proxy credentials properly. So:
In addition to the syntax understood by curl, it is possible to specify a proxy string with a user name but no password, in which case git will attempt to acquire one in the same way it does for other credentials.
See gitcredentials for more information.
The syntax thus is:
[protocol://][user[:password]@]proxyhost[:port]
This can be overridden on a per-remote basis; see
remote.<name>.proxy
.
2015 年 10 月更新
Since git 1.8.0和 commit 7bcb747 , 默认的 Windows 凭证助手是 wincred
,一个与 Windows 的凭据管理器交互的 git 凭据助手。
git config --global credential.helper wincred
原始答案(2013 年 3 月):
您可以使用 credential helper (git1.7.9+)喜欢git-credential-winstore在 Windows 上,以便存储您的凭据。
您将使用 ' git config --global credential.helper winstore
声明它'.
然后您可以在不输入用户名和密码的情况下声明您的代理:
git config --global http.proxy http://proxy.server.com:8080
(虽然我更喜欢 using environment variables http_proxy
and https_proxy
)
另请参阅“git: ' credential-cache
' is not a git command”
关于windows - 在代理后面使用 git,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15310167/