windows - 在代理后面使用 git

标签 windows git configuration proxy

我在代理后面。要使 git 正常工作,我必须添加

proxy = http://username:password@proxy.at.your.org:8080

.gitconfig

因为 usernamepassword 是我的系统凭据,所以这个解决方案很糟糕,因为我必须将它们存储为 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 authentication

Currently, 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.0commit 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/

相关文章:

c++ - C/C++ 中登录客户端软件的标准方法是什么?

windows - 通过局域网从另一台机器访问虚拟主机

c++ - 以编程方式确定网卡在 Windows 上是集成的还是独立的

git - 要求 git 查找 id_rsa 以外的其他 key

php - 如何更改 XAMPP 中 PHP 的默认路径?

c++ - 如何在源代码中设置程序执行的优先级?

git - git read-tree 后丢失的文件

Git 删除分支和所有相应的更改

c# - Sitecore 插入选项是否可以根据父项有条件地添加模板?

sql-server - SSIS:请求的 OLE DB 提供程序 SQLNCLI10.1 未注册