git:// 通过代理
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/5860888/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
git:// through proxy
提问by Mark Kahn
I'm behind a firewall that is blocking port 9418 (git) and am trying to install some tools that are explicitly doing a checkout of git://github.com/...
, so I can't switch to https for the checkout.
我在阻止端口 9418 (git) 的防火墙后面,并且正在尝试安装一些明确执行结帐的工具git://github.com/...
,因此我无法切换到 https 进行结帐。
So I'm wondering if it's possible to redirect all traffic to port 9418 through a proxy and if so how :)
所以我想知道是否可以通过代理将所有流量重定向到端口 9418,如果可以,如何:)
采纳答案by Alexander Gladysh
Have a look at core.gitproxy
setting in Git config.
看看Git config中的core.gitproxy
设置。
Quick googling revealed this script that may be useful (or may not — I did not try it): https://gist.github.com/49288
快速谷歌搜索发现这个脚本可能有用(或者可能没有——我没有尝试过):https: //gist.github.com/49288
回答by mppfiles
回答by ijw
Have you tried an ssh-based TCP tunnel? If you have an ssh server that (a) is outside your firewall and (b) allows IP forwarding, you can do:
您是否尝试过基于 ssh 的 TCP 隧道?如果您的 ssh 服务器 (a) 在您的防火墙之外并且 (b) 允许 IP 转发,您可以执行以下操作:
ssh -L localhost:9418:<remote>:9418 me@remote-ssh-server
or, if you have to run sshd on port 443 to get around your firewall,
或者,如果您必须在端口 443 上运行 sshd 以绕过防火墙,
ssh -P 443 -L localhost:9418:<remote-host>:9418 me@remote-ssh-server
Then, locally:
然后,本地:
git checkout git://localhost/...
Obviously this isn't transparent, and it's a little convoluted - there are no doubt tools out there that are more specifically targetted at the problem. However, I typically use this method because it uses tools I have to hand (ssh and a cheapo virtual server I rent).
显然,这并不透明,而且有点令人费解——毫无疑问,那里有更专门针对该问题的工具。但是,我通常使用这种方法,因为它使用我必须掌握的工具(ssh 和我租用的便宜的虚拟服务器)。
(I've actually never tried this with a git connection, but I see no reason why it wouldn't work. I've used it with many other single-TCP-port protocols without problem.)
(我实际上从来没有用 git 连接尝试过这个,但我看不出它为什么不起作用。我已经将它与许多其他单 TCP 端口协议一起使用了,没有问题。)
回答by Mihai Capot?
You need to make core.gitProxy
point to a proxy command that will connect git to the remote server through your SOCKS proxy. You can create a script with the following content to serve as a proxy command:
您需要core.gitProxy
指向一个代理命令,该命令将通过 SOCKS 代理将 git 连接到远程服务器。您可以创建一个包含以下内容的脚本作为代理命令:
nc -x <your_proxy_host>:<your_proxy_port>
The two parameters, representing the remote host and port, will be passed to the proxy command by git. If you name this script git-proxy
and make it accessible from your $PATH
, you can call git config
to set it:
代表远程主机和端口的两个参数将通过 git 传递给代理命令。如果您命名此脚本git-proxy
并使其可从您的 访问$PATH
,则可以调用git config
来设置它:
git config --global --add core.gitProxy git-proxy