克隆公司git仓库

时间:2015-12-05 12:02:17

标签: git http-proxy

我通常在代理后面使用git。因此我在全局配置中设置了这些。 git config -l --global包含http& HTTPS。

但是,为了访问公司git仓库,我必须取消设置全局代理,然后克隆。

有没有其他选择,我不必像这样更改全局设置?

3 个答案:

答案 0 :(得分:1)

您是否尝试过为let dict = scene.childrenByZPosition() dict[0] // [1, 3, 4] dict[1] // [0, 2] Paths.get("c:", "desktop", "nativelog.txt").toString(); http_proxy设置环境变量?

在SO上看看这两个答案:

Only use a proxy for certain git urls/domains?

How to temporarily disable git http proxy

答案 1 :(得分:1)

最好的方法是编写一个包含代理设置和取消设置代理的批处理文件并运行它。

Configure Git proxy 使用git代理命令

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代理CommandPHP

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

如何验证当前设置的Git代理?

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

答案 2 :(得分:1)

Git记住了3个不同的配置文件:

  • 系统范围配置
  • 用户范围配置
  • 第二个用户范围的配置
  • 本地回购配置

注意:以下教程假设您的代理配置已保存在全局或用户特定的配置中,例如OP。

从我们现有的仓库中删除代理

我们可以通过简单的cd到目录并运行来删除现有公司存储库中的代理:

git config --local --add http.proxy ""

这会将代理设置为空字符串,git用它来指定直接通信。

克隆没有代理的仓库

这种情况比较棘手,因为我们需要取消设置代理,克隆和重新配置代理。为此,我们可以编写一个名为" proxyless-clone"的简单bash脚本。 (名称并不重要)执行以下步骤:

#!/bin.sh
http_proxy=$(git config http.proxy)
https_proxy=$(git config https.proxy)
git config --global --unset http.proxy
git config --global --unset https.proxy
git clone "$1"
git config --global http.proxy "$http_proxy"
git config --global https.proxy "$https_proxy"

这个脚本仍有一些"问题",即2个实例无法同时运行而不会搞乱git配置文件(将其视为线程错误),但对于某些内容和1-只拍摄像克隆这样的东西,我认为这不会是一个问题。