How do I pull from a Git repository through an HTT

2018-12-31 13:56发布

Note: while the use-case described is about using submodules within a project, the same applies to a normal git clone of a repository over HTTP.

I have a project under Git control. I'd like to add a submodule:

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

But I get

...
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'

I have my HTTP_PROXY set up:

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

I even have a global Git setting for the http proxy:

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

Has anybody gotten HTTP fetches to consistently work through a proxy? What's really strange is that a few project on GitHub work fine (awesome_nested_set for example), but others consistently fail (rails for example).

26条回答
墨雨无痕
2楼-- · 2018-12-31 14:41

On Windows, if you don't want to put your password in .gitconfig in the plain text, you can use

It authenticates you against normal or even Windows NTLM proxy and starts localhost-proxy without authentication.

In order to get it run:

  • Install Cntml
  • Configure Cntml according to documentation to pass your proxy authentication
  • Point git to your new localhost proxy:

    [http]
        proxy = http://localhost:3128       # change port as necessary
    
查看更多
笑指拈花
3楼-- · 2018-12-31 14:41

Just to post this as it is the first result on Google, this blog post I found solves the problem for me by updated the curl certificates.

http://www.simplicidade.org/notes/archives/2011/06/github_ssl_ca_errors.html

查看更多
孤独寂梦人
4楼-- · 2018-12-31 14:43

You could too edit .gitconfig file located in %userprofile% directory on Windows system (notepad %userprofile%.gitconfig) or in ~ directory on Linux system (vi ~/.gitconfig) and add a http section as below.

Content of .gitconfig file :

[http]
        proxy = http://proxy.mycompany:80
查看更多
步步皆殇っ
5楼-- · 2018-12-31 14:43

Set Git credential.helper to wincred.

git config --global credential.helper wincred

Make sure there is only 1 credential.helper

git config -l

If there is more than 1 and it's not set to wincred remove it.

git config --system --unset credential.helper

Now set the proxy with no password.

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

Check that all the settings that you added looks good....

git config --global -l

Now you good to go!

查看更多
一个人的天荒地老
6楼-- · 2018-12-31 14:43

you can use:

git config --add http.proxy http://user:password@proxy_host:proxy_port
查看更多
柔情千种
7楼-- · 2018-12-31 14:44

Use proxychains

proxychains git pull ...

update: proxychains is discontinued, use proxychains-ng instead.

查看更多
登录 后发表回答