使用不同的代理推送多个远程控制器,每个分支使用单个命令

时间:2016-02-16 13:22:24

标签: git azure proxy gitlab

我希望每个分支都git push,它会推送到我的2个遥控器(每个分支都有不同的遥控器)。

我确实为每个分支尝试了这个:

git remote set-url --add --push all repo1
git remote set-url --add --push all repo2
git branch --set-upstream-to=all/master

这应该可行,但我有代理问题。 repo1位于Intranet中的GitLab仓库中,不使用代理,但repo2位于Azure中且需要代理。因此git push失败。

如何在同一个遥控器中使用不同代理的URL?或者可能还有一些其他想法如何解决这个问题?

1 个答案:

答案 0 :(得分:1)

最简单的方法是编写2个批处理文件,一个用于设置代理,另一个用于取消设置代理并进行管理。

您可以使用git bash中的以下命令设置Git代理。为HTTP和HTTPS代理设置。

git config --global http.proxy http://username:password@proxy.server.com:8080
git config --global https.proxy http://username:password@proxy.server.com:8080

//Replace username with your proxy username
//Replace password with your proxy password
//Replace proxy.server.com with the proxy domain URL.
//Replace 8080 with the proxy port no configured on the proxy server.

要取消设置Git代理,请使用以下命令

git config --global --unset http.proxy
git config --global --unset https.proxy

How to configure Git proxyHow to unset the Git Proxy上查看我的博客了解详情

相关问题