简体   繁体   English

如何强制git子模块出现在主存储库中并提交?

[英]How do I force git submodules to be present and commited in the main repository?

Is it possible to add Git submodules files and to commit them to my root git module? 是否可以添加Git子模块文件并将其提交到我的root git模块?

I deeply searched and never found the answer. 我进行了深入搜索,却找不到答案。

如果您确实想做这样的事情,最好使用git子树而不是git子模块,这样外部代码便成为您主存储库的一部分。

No, this is not possible using submodules. 不,使用子模块是不可能的。

But a repository can be cloned with its submodules using the --recursive flag to git clone : 但是可以使用--recursive标志对git clone来克隆存储库及其子模块:

--recursive -递归
--recurse-submodules --recurse-子模块

After the clone is created, initialize all submodules within, using their default settings. 创建克隆后,使用其默认设置初始化其中的所有子模块。 This is equivalent to running git submodule update --init --recursive immediately after the clone is finished. 这等效于克隆完成后立即运行git submodule update --init --recursive This option is ignored if the cloned repository does not have a worktree/checkout (ie if any of --no-checkout / -n , --bare , or --mirror is given) 这个选项被忽略,如果克隆库不具有worktree /结帐(即,如果任何的--no-checkout / -n--bare ,或--mirror给出)

Many projects instruct users to clone using this flag in their README, getting started guide, or elsewhere. 许多项目指示用户在自述文件,入门指南或其他地方使用此标志进行克隆。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM