从 github 克隆 git 存储库,无需完整 URL

mam*_*miu 1 git github

是否可以在没有完整 URL 的情况下从 github 克隆 git 存储库?

例如:
当我必须运行这个:git clone https://github.com/foo/bar.git
我想输入这个:git clone foo/bar

我在网上看到了解决方案,但现在找不到了。

Noe*_*lkd 5

如果您只想使用以下方法执行此操作,git可以.gitconfig通过添加 url 别名来编辑文件,如下所示:

[url "<actual url base>"]
    insteadOf = <other url base>
Run Code Online (Sandbox Code Playgroud)

例如:

[url "https://github.com/"]
    insteadOf = gh:
Run Code Online (Sandbox Code Playgroud)

然后你可以这样做:

 git clone gh:foo/bar.git
Run Code Online (Sandbox Code Playgroud)

它并不完全是您所要求的,但可以替代安装另一个命令行工具。

感谢git 文档Stefan Majewsky