【问题标题】:Modify the url automatically when using git clone使用 git clone 时自动修改 url
【发布时间】:2016-01-11 19:46:44
【问题描述】:

JHBuild 使用 git 协议而不是 https 来克隆文件。我正在一个代理环境中工作,它可以防止使用 git 协议进行克隆。

示例 gnome repo 的 git url:git://git.gnome.org/gnome-common

示例 gnome repo 的 http url: http://git.gnome.org/浏览/gnome-common.

JHBuild 执行克隆命令时,有什么办法可以自动将 git url 转换为 https 格式。

【问题讨论】:

    标签: git proxy gnome jhbuild


    【解决方案1】:

    gnome 模块集将 git.gnome.org 定义为使用 git:// 但这可以在 jhbuildrc 文件中更改。

    在 jhbuildrc 中添加以下行。

    repos['git.gnome.org'] = 'http://git.gnome.org/browse/'

    该文件通常存在于 ~/.config 中。如果不存在,则创建 jhbuildrc 文件。

    【讨论】:

      【解决方案2】:

      如果由于代理或防火墙的原因,您无法克隆带有 git:// url 的存储库,这里有一个小 git 配置,即使您输入 git:// URL,它也会强制 git 使用 http://

      git config --global url."http://".insteadOf git://
      

      使用此命令,它将在您的.gitconfig 中添加以下行:

      [url "http://"]   
          insteadOf = git://
      

      这样,您在克隆 repo 时不必关心使用 git://http://,这两个 url 都可以使用。

      也许是一个众所周知的调整,但最近发现它......

      【讨论】:

      • 如果您注意到我提到的 url,您可以看到 http 版本中有一个额外的“浏览”。有什么办法可以解决吗?
      • 需要修改url广告添加浏览?
      • 我不这么认为,因为它与 git 无关,它是你的系统如何工作的
      猜你喜欢
      • 2014-03-11
      • 2018-05-31
      • 1970-01-01
      • 2020-11-28
      • 1970-01-01
      • 1970-01-01
      • 2017-09-30
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多