对于存在 submodule 的 git 仓库怎么 clone 最少的代码?对比 git clone --depth=1
怪我咯
怪我咯 2017-05-02 09:51:54
0
1
1091

单纯从 github 下载使用软件时,可以通过 depth 参数来下载最先的代码,但是对于有 submodule 的项目,执行 git submodule update --init --recursive --depth=1 ,因为 submodule 是 shallow clone, 所以无法 checkout 到目标 commit。

这种情况有什么办法解决?

怪我咯
怪我咯

走同样的路,发现不同的人生

reply all(1)
仅有的幸福

I only found a method that fetch/clone once, which is quite troublesome:

  1. git submodule update --init --depth=1 At this time, the commit obtained by clone is usually not the one registered by the submodule, so an error will be reported

  2. git ls-tree HEAD:(submodule的路径) Find the commit you want, such as

    `160000 commit abb03163aeafb8b7fc1efd2413d9f077bcdbeed9  tidy-html5` 的 `abb031`就是
  3. cd to the clone repo of submodule (such as .git/modules/tidy-html5), fetch那个commit git fetch abb031

  4. git submodule update --no-fetch

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!