如何使用相对路径浅层克隆本地git存储库?

Cir*_*四事件 6 git

本地目录的浅克隆需要file://如下所述:git clone:warning:在本地克隆中忽略--depth; 使用file://代替

但是如何使用相对路径呢?

例如:如果我myrepo在当前目录中有一个repo ,那么我这样做:

git clone --depth 1 file://mymodule mymodule2
Run Code Online (Sandbox Code Playgroud)

然后它失败了:

Cloning into 'mymodule2'...
fatal: No path specified. See 'man git-pull' for valid url syntax
Run Code Online (Sandbox Code Playgroud)

如果我尝试:

git clone --depth 1 file://./mymodule mymodule2
Run Code Online (Sandbox Code Playgroud)

它失败了:

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.
Run Code Online (Sandbox Code Playgroud)

我能找到的唯一解决方法是将其转换为绝对路径,从以下开始/:

git clone --depth 1 "file://$(pwd)/mymodule" mymodule2
Run Code Online (Sandbox Code Playgroud)

这种行为有一个深刻的原因,还是只是马车?

也许文件URI根本不支持相对路径:

git 2.14.1.

mab*_*mab -3

您应该尝试不使用file://前缀:

git clone --depth 1 ./mymodule mymodule2
Run Code Online (Sandbox Code Playgroud)