【问题标题】:Working with git behind proxy在代理后面使用 git
【发布时间】:2013-02-24 22:51:00
【问题描述】:

我支持代理。要让git 工作,我必须添加

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

.gitconfig

因为usernamepassword 是我的系统凭据,所以这个解决方案很糟糕,因为我必须将它们存储为cleartext

我使用的是Google Chrome,我不需要设置任何代理设置,因为它使用系统代理设置。

如何使用git 做到这一点?

【问题讨论】:

  • 注意:使用 git 2.8(2016 年 3 月),您将能够使用常规 git 凭证助手来获取与代理用户登录关联的密码。见my edited answer below

标签: windows git configuration proxy


【解决方案1】:

2016 年 2 月更新:

使用 git 2.8(2016 年 3 月),您不必在 url 中以明文形式嵌入密码。

commit 372370fcommit ef97639(2016 年 1 月 26 日)Knut Franke (``)
帮助者:Junio C Hamano (gitster)Eric Sunshine (sunshinebell28)Elia Pinto (devzero2000)
(由 Junio C Hamano -- gitster -- 合并到 commit 30f302f,2016 年 2 月 3 日)

http: 使用凭证 API 处理代理认证

目前,将代理凭据传递给 curl 的唯一方法是将它们包含在代理 URL 中。通常,这意味着它们最终会以一种或另一种方式未加密的磁盘上(通过包含在~/.gitconfig、shell 配置文件或历史记录中)。
由于代理身份验证通常使用域用户,因此凭据可能是安全敏感的;因此,需要一种更安全的凭据传递方式。

如果配置的代理包含用户名但不包含密码,则查询 凭证 API 之一。此外,请确保我们批准/拒绝代理凭据 适当地。 所以:

除了 curl 可以理解的语法之外,还可以指定一个 带有用户名但没有密码的代理字符串,在这种情况下 git 将尝试以与它相同的方式获取一个其他凭据。
请参阅gitcredentials 了解更多信息。
因此语法是:

[protocol://][user[:password]@]proxyhost[:port]

这可以在每个远程的基础上被覆盖;见remote.<name>.proxy


2015 年 10 月更新

Since git 1.8.0commit 7bcb747,默认的 Windows 凭据助手是 wincred,这是一个与 Windows 凭据管理器交互的 git 凭据助手。

 git config --global credential.helper wincred

原始答案(2013 年 3 月):

您可以在 Windows 上使用 credential helper (git1.7.9+) 之类的 git-credential-winstore 来存储您的凭据。
您将使用“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


【讨论】:

    猜你喜欢
    • 2011-07-28
    • 2020-06-21
    • 1970-01-01
    • 1970-01-01
    • 2016-08-06
    • 2015-10-04
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多