git子模块添加仅选择最新提交 [英] git submodule add only pick latest Commit
问题描述
我有一个依赖于其他项目的项目,所以我使用git子模块.
但是我的项目只对最新提交感兴趣,我不希望所有提交都回到开始.
I have a project that depends on other projects so I use git submodule.
But my project is only interested with latest commit, I don't want all of the commits back to the beginning.
例如 openssl zip 为6.6MB,但克隆存储库为71.76MB.
我只需要6.6MB,但是具有git子模块的优势.
For example openssl zip is 6.6MB but cloning repo is 71.76MB.
I want only the 6.6MB but with advantage of git submodule.
有没有出路?
推荐答案
是的,您可以做到.
有一个--depth
标志,可以将其传递给子模块.
--depth
标志的使用方式与克隆存储库时所使用的方式相同,并且您仅希望克隆最新的提交.
There is the --depth
flag which can be passed to the submodule.
The --depth
flag can be used in the same way as you use it when cloning repository and you wish to clone only the latest commit.
将
--depth
选项添加到git submodule
的添加和更新命令中,然后将其传递给克隆命令.
当子模块很大并且您对除最新提交以外的任何东西都不感兴趣时,这很有用.
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>
完整文档可在此处找到.
这篇关于git子模块添加仅选择最新提交的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!