使用域设置Git代理

时间:2015-09-01 06:42:40

标签: git proxy

我想通过 Windows 7 上的代理在工作中使用 git 。我的公司有各种代理。为了通过Python pip使用的代理,我使用了Cntlm程序。使用Cntlm,我能够指定我的域\用户名和密码,并使用它来连接/绕过代理服务器。

我不想使用git。我不知道将域名放在git的代理设置中的位置。以下是我在Windows 7上的cmd中执行的步骤。

set HTTP_PROXY=http://domain\username:password@proxyaddress:proxyport
git config --global http.proxy $HTTP_PROXY
git clone git://github.com/destination.git folder

尽管我的所有信息都是正确的,并且Cntlm使用相同的信息,这样可以保持超时。有人可以协助正确的程序让git通过这样的代理工作吗?

2 个答案:

答案 0 :(得分:3)

要从https代理设置中受益,您至少应该使用https协议。

# not:
git clone git://github.com/destination.git folder
# but
git clone https://github.com/destination.git folder

注意:如果设置了环境变量,即使没有完成git config http(s).proxy,它也会被git选中。
你应该同时定义HTTP_PROXY和HTTP_PROXY。

您会在“Setting git to work behind NTLM-authenticated proxy: cntlm to the rescue ”找到更完整的示例 OP Cornel Verster提及in the comments

  

使用Cntlm时,您应该将git http.proxy设置为localhost:3128以及HTTP_PROXY127.0.0.1:3128)和HTTPS_PROXY127.0.0.1:3128 )变量。

答案 1 :(得分:0)

在Windows上,您必须使用%YOUR_VAR%来引用您的变量。 所以我认为主要问题是这个错误。 你已经在这里发布了一篇文章 - > How do I pull from a Git repository through an HTTP proxy?