【问题标题】:What are the supported git url formats?支持的 git url 格式有哪些?
【发布时间】:2015-08-04 13:46:20
【问题描述】:

Git 接受许多不同的 url 格式(例如 ssh、http、https 等)。是否有任何规范/官方文档可以找到支持的 git url 格式?

我写了一个git url parser,我想确保它所做的事情是正确的。

Here, on YonderGit,我找到了下面的列表。它不完整,因为https://<token>:x-oauth-basic@host.xz/path/to/repo.git 不存在。

安全外壳传输协议

  • ssh://user@host.xz:port/path/to/repo.git/
  • ssh://user@host.xz/path/to/repo.git/
  • ssh://host.xz:port/path/to/repo.git/
  • ssh://host.xz/path/to/repo.git/
  • ssh://user@host.xz/path/to/repo.git/
  • ssh://host.xz/path/to/repo.git/
  • ssh://user@host.xz/~user/path/to/repo.git/
  • ssh://host.xz/~user/path/to/repo.git/
  • ssh://user@host.xz/~/path/to/repo.git
  • ssh://host.xz/~/path/to/repo.git
  • user@host.xz:/path/to/repo.git/
  • host.xz:/path/to/repo.git/
  • user@host.xz:~user/path/to/repo.git/
  • host.xz:~user/path/to/repo.git/
  • user@host.xz:path/to/repo.git
  • host.xz:path/to/repo.git
  • rsync://host.xz/path/to/repo.git/

Git 传输协议

  • git://host.xz/path/to/repo.git/
  • git://host.xz/~user/path/to/repo.git/

HTTP/S 传输协议

  • http://host.xz/path/to/repo.git/
  • https://host.xz/path/to/repo.git/

本地(文件系统)传输协议

  • /path/to/repo.git/
  • path/to/repo.git/
  • ~/path/to/repo.git
  • file:///path/to/repo.git/
  • file://~/path/to/repo.git/

【问题讨论】:

    标签: git github ssh


    【解决方案1】:

    您可以在urlmatch.hurlmatch.c 中看到git 准备解析的内容。
    这是 t0110-urlmatch-normalization.sh 使用的,它说明了 git 测试的可能 url 的完整列表。

    url.c 确实提到:

    根据 STD66 (RFC3986) 的有效 URL 方案集是“[A-Za-z][A-Za-z0-9+.-]*”。
    但是使用稍微宽松的“[A-Za-z0-9][A-Za-z0-9+.-]*”检查,因为早期版本的检查使用了“[A-Za-z0-9]+”,因此不会破坏任何远程助手。

    【讨论】:

    • 我同意,s̶o̶m̶e̶t̶i̶m̶e̶s̶ 经常检查源代码是最好的文档。 :) 谢谢!
    • @IonicăBizău 是的,我怀疑github.com/git/git/blob/master/t/… 将是一段时间内最新的 git url 列表。
    • 这也很有用!
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2012-12-14
    • 2015-08-05
    • 2014-08-04
    • 2011-09-10
    • 2021-01-09
    • 2019-04-08
    • 1970-01-01
    相关资源
    最近更新 更多