【发布时间】:2018-04-28 16:30:56
【问题描述】:
本地目录的浅层克隆需要file://,解释如下:git clone: warning: --depth is ignored in local clones; use file:// instead
但是如何使用相对路径呢?
例如:如果我在当前目录中有一个 repo myrepo,然后我这样做:
git clone --depth 1 file://mymodule mymodule2
然后它失败了:
Cloning into 'mymodule2'...
fatal: No path specified. See 'man git-pull' for valid url syntax
如果我尝试:
git clone --depth 1 file://./mymodule mymodule2
它失败了:
Cloning into 'mymodule2'...
fatal: '/./mymodule' does not appear to be a git repository
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
我能找到的唯一解决方法是将其转换为以/ 开头的绝对路径:
git clone --depth 1 "file://$(pwd)/mymodule" mymodule2
这种行为有什么深刻的原因,还是只是有问题?
也许文件 URI 根本不支持相对路径:
- File Uri Scheme and Relative Files
- https://superuser.com/questions/210263/file-to-point-a-relative-file-to-current-directory
git 2.14.1.
【问题讨论】:
-
来自 git clone 的文档:
git clone C:\folder1 folder2kernel.org/pub/software/scm/git/docs/git-clone.html#URLS -
@IvanSheigets 但
C:\不是绝对路径吗?它是否适用于--depth而没有file://?在 Linux 中--depth需要file://。 -
你是对的:URL/URI 根本不允许相对路径。 Git 可能应该在这里拥抱并扩展,以便无论如何都允许它。
-
这是杀手锏。非常感谢。太多人说这是不可能的。
标签: git