我正在开发一个带子模块的项目。我在.gitmodules
中有特定的分支,我希望在特定的提交中检出子模块。这些提交会自动与父仓库一起存储。
现在,如果我在一台Linux机器上(在Ubuntu 16.04.3 LTS上测试)在一个空目录中使用git version 2.7.4
克隆父repo,我就会得到我想要的。输出看起来像这样。
$ git clone git@github.com:redsandro/myproject.git --recursive --branch develop --single-branch
Cloning into 'myproject'...
remote: Counting objects: 105, done.
remote: Compressing objects: 100% (33/33), done.
remote: Total 105 (delta 11), reused 29 (delta 7), pack-reused 65
Receiving objects: 100% (105/105), 31.45 KiB | 0 bytes/s, done.
Resolving deltas: 100% (34/34), done.
Checking connectivity... done.
Submodule 'api' (git@github.com:redsandro/api.git) registered for path 'api'
Cloning into 'api'...
remote: Counting objects: 30647, done.
remote: Compressing objects: 100% (137/137), done.
remote: Total 30647 (delta 96), reused 134 (delta 58), pack-reused 30442
Receiving objects: 100% (30647/30647), 4.78 MiB | 910.00 KiB/s, done.
Resolving deltas: 100% (20032/20032), done.
Checking connectivity... done.
Submodule path 'api': checked out 'd651e9dd72acc4af7e3f98507373490c3be77756'
现在,当我的同事在一个空文件夹中使用git version 2.13.6 (Apple Git-96)
的Apple MacBook MacOS / OSX计算机上克隆父回复时,我在子模块上出现错误,并且当没有错误时,仍然有一堆删除上演。
输出如下:
$ git clone git@github.com:redsandro/myproject.git --recursive --branch develop --single-branch
Cloning into 'myproject'...
remote: Counting objects: 105, done.
remote: Compressing objects: 100% (33/33), done.
remote: Total 105 (delta 11), reused 29 (delta 7), pack-reused 65
Receiving objects: 100% (105/105), 31.45 KiB | 10.48 MiB/s, done.
Resolving deltas: 100% (34/34), done.
Submodule 'api' (git@github.com:redsandro/api.git) registered for path 'api'
Cloning into '/Users/mycolleague/projects/myproject/api'...
remote: Counting objects: 1431, done.
remote: Compressing objects: 100% (1149/1149), done.
remote: Total 1431 (delta 483), reused 640 (delta 190), pack-reused 0
Receiving objects: 100% (1431/1431), 700.42 KiB | 1.65 MiB/s, done.
Resolving deltas: 100% (483/483), done.
error: Server does not allow request for unadvertised object d651e9dd72acc4af7e3f98507373490c3be77756
Fetched in submodule path 'api', but it did not contain d651e9dd72acc4af7e3f98507373490c3be77756. Direct fetching of that commit failed.
为什么结果有差异?请记住:
.git
目录的新空目录中测试的;