我有一个项目依赖于其他项目,所以我使用 git 子模块。
但我的项目只对最新的提交感兴趣,我不希望所有的提交都回到开头。
例如openssl zip是 6.6MB,但克隆仓库是 71.76MB。
我只想要 6.6MB,但可以利用 git 子模块。
还有出路吗?
最佳答案
是的,你可以做到。
有一个--深度
标志可以传递给子模块。
--深度
标志的使用方式与克隆存储库时使用它的方式相同,并且您希望仅克隆最新的提交。
Add the
--depth
option to the add and update commands ofgit submodule
, which is then passed on to the clone command.
This is useful when the submodule(s) are huge and you're not really interested in anything but the latest commit.
git submodule add --depth 1 -- <url>
git submodule update --depth -- <url>
可以找到完整文档 here .
关于git 子模块添加仅选择最新的提交,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34283199/