注:虽然使用情况说明是关于使用的子系统内的一个项目,同样适用于一个正常的 git clone 一个仓库在HTTP。

我有一个项目下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

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

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

有人得到HTTP取一致地工作,通过代理?什么是真正奇怪的是,一些项目上的审查工作的现(awesome_nested_set 例如),但其他一直失败( 例如)。

有帮助吗?

解决方案 3

最终工作的是设置http_proxy环境变量。我已正确设置HTTP_PROXY,但git显然更喜欢小写版本。

其他提示

您还可以设置Git在全局配置属性http.proxy中使用的HTTP代理:

git config --global http.proxy http://proxy.mycompany:80

使用代理进行身份验证:

git config --global http.proxy http://mydomain\\myusername:mypassword@myproxyserver:8080/

(感谢 @EugeneKulabuhov @ JaimeReynoso 用于身份验证格式。)

这已经有了一些很好的答案。但是,我认为我会填写,因为一些代理服务器要求您使用用户ID和密码进行身份验证。有时这可能在一个域上。

因此,例如,如果您的代理服务器配置如下:

Server: myproxyserver
Port: 8080
Username: mydomain\myusername
Password: mypassword

然后,使用以下命令添加到.gitconfig文件中:

git config --global http.proxy http://mydomain\\myusername:mypassword@myproxyserver:8080

不要担心https。只要指定的代理服务器支持http和https,配置文件中的一个条目就足够了。

然后,您可以通过执行cat .gitconfig验证该命令是否已成功将条目添加到<=>文件中:

在文件末尾,您将看到如下条目:

[http]
    proxy = http://mydomain\\myusername:mypassword@myproxyserver:8080

就是这样!

看起来你正在Windows上使用Gitw编译Git(或者可能是另一个我没有听说过的)。有一些方法可以调试这个:我相信git的所有http代理工作都是由curl完成的。在运行git:

之前设置此环境变量
GIT_CURL_VERBOSE=1

这至少可以让你了解幕后发生的事情。

如果您只想在指定的存储库上使用代理,则不需要在其他存储库中使用。当您-c, --config <key=value>存储库时,首选方法是git clone选项。 e.g。

$ git clone https://chromium.googlesource.com/chromium/tools/depot_tools.git --config "http.proxy=proxyHost:proxyPort"

当您的网络团队通过重写证书进行ssl检查时,然后使用http url而不是https,并结合设置此var对我有效。

git config --global http.proxy http://proxy:8081

您也可以编辑.gitconfig文件位于Windows系统上的%userprofile%目录( notepad%userprofile%.gitconfig )或Linux系统上的〜目录中(< em> vi~ / .gitconfig )和添加http部分,如下所示。

.gitconfig文件的内容:

[http]
        proxy = http://proxy.mycompany:80

这是一个老问题,但如果您使用的是Windows,请考虑在通过https网址检索时设置HTTPS_PROXY。为我工作!

对我来说,git://虽然https://确实无法通过代理工作。这引起了一些麻烦,因为我运行的脚本都使用了git://所以我不能轻易地改变它们。但是我找到了这个GEM

git config --global url."https://github.com/".insteadOf git://github.com/

我发现http.proxyGIT_PROXY_COMMAND都不适用于我经过身份验证的http代理。代理不会以任何方式触发。但我找到了解决这个问题的方法。

  1. 安装开瓶器或其他您想要的替代品。
  2. 创建一个authfile。 authfile的格式为:user_name:passworduser_namepassword是您访问代理的用户名和密码。要创建这样的文件,只需运行如下命令:echo "username:password" > ~/.ssh/authfile

  3. 修改~/.ssh/config,并确保其权限为644chmod 644 ~/.ssh/config

  4. 以github.com为例,将以下行添加到git@github.com

    Host    github.com
            HostName        github.com
            ProxyCommand    /usr/local/bin/corkscrew <your.proxy> <proxy port> %h %p <path/to/authfile>
            User            git
    

    现在,只要您使用<=>执行任何操作,它就会自动使用代理。你也可以轻松地对 Bitbucket 做同样的事情。

    这并不像其他方法那么优雅,但它就像一个魅力。

在窗户,如果你不想要把你的密码。gitconfig在纯文本,可以使用

它进行身份验证你对正常的,甚至Windows NTLM代理,并开始localhost代理没有身份验证。

为了得到它运行:

  • 安装Cntml
  • 配置Cntml根据文件通过代理的身份验证
  • 点缝你的新localhost代理:

    [http]
        proxy = http://localhost:3128       # change port as necessary
    

对我而言,它的作用是:

sudo apt-get install socat

使用以下命令在$ BIN_PATH / gitproxy中创建一个文件:

#!/bin/sh 
_proxy=192.168.192.1 
_proxyport=3128 
exec socat STDIO PROXY:$_proxy:$1:$2,proxyport=$_proxyport

别忘了给它执行权限

chmod a+x gitproxy

运行以下命令来设置环境:

export PATH=$BIN_PATH:$PATH
git config --global core.gitproxy gitproxy

只是发布这个,因为它是谷歌的第一个结果,我发现这篇博文通过更新卷曲证书解决了我的问题。

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

设置代理到git

命令

git config --global http.proxy http://user:password@domain:port

例如

git config --global http.proxy http://clairton:123456@proxy.clairtonluz.com.br:8080

这对我有用。

git config --global http.proxy proxy_user:proxy_passwd@proxy_ip:proxy_port

我遇到了同样的问题,修复方式稍有不同:使用HTTP支持重新构建GIT

git:协议无法通过我的公司防火墙工作。

例如,这个超时:

git clone git://github.com/miksago/node-websocket-server.git

curl github.com工作得很好,所以我知道我的http_proxy环境变量是正确的。

我尝试使用http,如下所示,但立即收到错误。

git clone http://github.com/miksago/node-websocket-server.git

->>>  fatal: Unable to find remote helper for 'http' <<<-

我试着像这样重新编译git:

./configure  --with-curl --with-expat

但仍然有致命的错误。

最后,经过几个令人沮丧的时间后,我读了配置文件, 并看到了这个:

  

#define CURLDIR = / foo / bar如果您的curl标题和库文件在

中      

#/ foo / bar / include和/ foo / bar / lib目录。

我记得那时,我没有从源头上遵守curl,所以就这样了 寻找头文件。果然,他们没有安装。那就是问题所在。 Make没有抱怨丢失的头文件。所以 我没有意识到--with-curl选项什么都没做(实际上是我的git版本中的默认选项)。

我做了以下修复:

  1. 添加了make:

    所需的标头
    yum install curl-devel
    (expat-devel-1.95.8-8.3.el5_5.3.i386  was already installed).
    
  2. /usr/local删除git*(因为我希望新安装在那里生效)。

    我只是从/usr/local/share/usr/local/libexec

  3. 删除expat
  4. 搜索包含configure和<=>头文件的include目录,然后(因为我已阅读<=>)将这些添加到环境中,如下所示:

    export CURLDIR=/usr/include 
    export EXPATDIR=/usr/include
    
  5. 使用以下选项Ran <=>,这些选项再次在<=>文件本身中进行了描述,也是默认值,但是到底是什么:

    git clone http://github.com/miksago/node-websocket-server.git
    Cloning into 'node-websocket-server'...
    * Couldn't find host github.com in the .netrc file, using defaults
    * About to connect() to proxy proxy.entp.attws.com port 8080
    *   Trying 135.214.40.30... * connected
    ...
    
  6. 现在<=>通过我的公司防火墙与<=>一起工作:

    <*>

你可以使用:

git config --add http.proxy http://user:password@proxy_host:proxy_port

将Git credential.helper设置为wincred。

git config --global credential.helper wincred

确保只有1个credential.helper

git config -l

如果超过1并且未设置为wincred则将其删除。

git config --system --unset credential.helper

现在设置代理没有密码。

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

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

git config --global -l

现在你好好去!

这不是您的代理问题。这是github(或git)的问题。在linux上的git-1.6.0.1上它也失败了。已经报告了错误(由你否更小)。

确保删除你的馅饼,它们已经在google上了。编辑:一定是在做梦,我想你不能删除它们。请改用 Gist

$ http_proxy适用于 http://github.com .... $ https_proxy适用于 https://github.com ...

适用于Windows

转到 - <!> gt; C:/用户/ USER_NAME / gitconfig

使用以下详细信息更新gitconfig文件

[HTTP]

[HTTPS]

proxy = https://your_proxy:your_port

[HTTP]

proxy = http://your_proxy:your_port

如何检查代理和端口号?

Internet Explorer - <!> gt;设置 - <!> gt;互联网选项 - <!> gt;连接 - <!> gt;局域网设置

使用代理链

proxychains git pull ...

更新:已停止使用代理链,请使用 proxychains-ng 代替。

我使用https解决了代理...某些代理甚至不检查https。

Microsoft Windows [Version 6.1.7601]
Copyright (c) 2009 Microsoft Corporation.  All rights reserved.

c:\git\meantest>git clone http://github.com/linnovate/mean.git
Cloning into 'mean'...
fatal: unable to access 'http://github.com/linnovate/mean.git/': Failed connect
to github.com:80; No error

c:\git\meantest>git clone https://github.com/linnovate/mean.git
Cloning into 'mean'...
remote: Reusing existing pack: 2587, done.
remote: Counting objects: 27, done.
remote: Compressing objects: 100% (24/24), done.
rRemote: Total 2614 (delta 3), reused 4 (delta 0)eceiving objects:  98% (2562/26

Receiving objects: 100% (2614/2614), 1.76 MiB | 305.00 KiB/s, done.
Resolving deltas: 100% (1166/1166), done.
Checking connectivity... done

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

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

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

许多人都回答了这个问题,但这只适用于使用auth支持代理的 Winodws 用户。

重新安装(首先失败,不要删除)。

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"

如果您在用户/传递使用中有任何特殊字符 url_encode

正如@ user2188765已经指出的那样,尝试用git://替换存储库的http[s]://协议。另请参见此答案

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top