注意:虽然所描述的用例是关于在项目中使用子模块,但同样适用于通过HTTP的存储库的普通git克隆。

我有一个Git控制下的项目。我想增加一个子模块:

git submodule add http://github.com/jscruggs/metric_fu.git vendor/plugins/metric_fu

但是我知道

...
got 1b0313f016d98e556396c91d08127c59722762d0
got 4c42d44a9221209293e5f3eb7e662a1571b09421
got b0d6414e3ca5c2fb4b95b7712c7edbf7d2becac7
error: Unable to find abc07fcf79aebed56497e3894c6c3c06046f913a under http://github.com/jscruggs/metri...
Cannot obtain needed commit abc07fcf79aebed56497e3894c6c3c06046f913a
while processing commit ee576543b3a0820cc966cc10cc41e6ffb3415658.
fatal: Fetch failed.
Clone of 'http://github.com/jscruggs/metric_fu.git' into submodule path 'vendor/plugins/metric_fu'

我有我的HTTP_PROXY设置:

c:\project> echo %HTTP_PROXY%
http://proxy.mycompany:80

我甚至有一个http代理的全局Git设置:

c:\project> git config --get http.proxy
http://proxy.mycompany:80

有人获得HTTP获取始终通过代理工作吗?真正奇怪的是,GitHub上的一些项目工作得很好(例如awesome_nested_set),但其他项目总是失败(例如rails)。


当前回答

对于Windows

转到-> C:/用户名/gitconfig

用以下细节更新gitconfig文件

(http)

(https)

proxy = https://your_proxy:your_port

(http)

proxy = http://your_proxy:your_port

如何检查您的代理和端口号?

ie浏览器—>设置—> Internet选项—>连接—>局域网设置

其他回答

设置Git凭证。助我一臂之力。

git config --global credential.helper wincred

确保只有1个credential.helper

git config -l

如果有多于1且未设置为将其移除。

git config --system --unset credential.helper

现在设置没有密码的代理。

git config --global http.proxy http://<YOUR WIN LOGIN NAME>@proxy:80

检查您添加的所有设置是否正常....

git config --global -l

现在你可以开始了!

当我的代理不需要身份验证时,上面的答案对我有用。如果您正在使用需要您进行身份验证的代理,那么您可以尝试CCProxy。我有一个关于如何设置的小教程,

http://blog.praveenkumar.co.in/2012/09/proxy-free-windows-xp78-and-mobiles.html

我可以推,拉,创造新的回购。一切都很顺利。如果你像我一样遇到Git的问题,请确保你干净地卸载并重新安装新版本。

使用proxychains

proxychains git pull ...

更新:proxychains已停产,请改用proxychains-ng。

这是许多人的回答,但这只是为windows用户谁是背后的代理与认证。

重新安装(第一次失败,不要删除)。

Goto ->
**Windows**
1. msysgit\installer-tmp\etc\gitconfig
    Under [http]
        proxy = http://user:pass@url:port

**Linux**
1. msysgit\installer-tmp\setup-msysgit.sh
      export HTTP_PROXY="http://USER:PASS@proxy.abc.com:8080"

如果在user/pass中有任何特殊字符,请使用url_encode

这是一个老问题,但如果你是在Windows上,如果你是通过https URL检索,也可以考虑设置HTTPS_PROXY。为我工作!