git子模块添加仅选择最新提交 [英] git submodule add only pick latest Commit

查看:78
本文介绍了git子模块添加仅选择最新提交的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个依赖于其他项目的项目,所以我使用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 --depthflag 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 of git 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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆