简体   繁体   English

在git superproject和子模块中签出

[英]Checkout in git superproject and submodules

Consider a superproject with a submodule. 考虑一个带有子模块的超级项目。 If the superproject is checked out to a previous commit, how to automatically check out the submodule to the corresponding commit ? 如果将超级项目检出到先前的提交,则如何自动将子模块检出到相应的提交?

Superproject : A - B 上级项目:A-B

Submodule : X - Y - Z 子模块:X-Y-Z

Superproject HEAD is on B, corresponding index on submodule is on Z. Imagine that in A, submodule index was in X. How can I automatically checkout submodule on X when I check out superproject in A ? 超级项目HEAD在B上,子模块上的对应索引在Z上。想象一下在A中,子模块索引在X中。当我在A中签出超级项目时,如何在X上自动签出子模块?

I can do it manually thanks to this question but it is not efficient for superproject with many submodules. 由于这个问题,我可以手动完成此操作,但对于具有许多子模块的超级项目而言,效率不高。

[Edit] By checkout, I mean using git checkout commitSHA1 . [编辑]通过checkout,我的意思是使用git checkout commitSHA1 According to the doc , 根据文档

Prepare to work on top of , by detaching HEAD at it (see "DETACHED HEAD" section), and updating the index and the files in the working tree. 准备通过在头上分离HEAD来进行工作(请参阅“分离的头”部分),并更新工作树中的索引和文件。

I want to recompile code as it was in superproject commit A (possibly tagged) without knowing explicitly corresponding submodules indexes. 我想重新编译代码,就像在超级项目提交A中一样(可能已标记),而又不知道显式对应的子模块索引。

I believe the command you're looking for is: 我相信您要查找的命令是:

git submodule update

That should get all your submodules to the right version (when run after your git checkout ) 那应该使您的所有子模块都达到正确的版本(在git checkout之后运行时)

http://git-scm.com/docs/git-submodule http://git-scm.com/docs/git-submodule

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

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