简体   繁体   English

git checkout版本,包括子模块

[英]git checkout version including submodules

How can I checkout a git repo including its submodules? 如何检出git repo及其子模块?

eg I have a repo A, with a submodule B, the commit history is as follows: 例如,我有一个回购A,带有一个子模块B,提交历史如下:

  • f7fe0a4 A, bcbaec2 B (latest) f7fe0a4 A,bcbaec2 B(最新)
  • 206c8dd A, bcbaec2 B 206c8dd A,bcbaec2 B
  • 0fd667c A, bcbaec2 B 0fd667c A,bcbaec2 B
  • 0ec21a1 A, e79fea0 B (older version) 0ec21a1 A,e79fea0 B(旧版本)

I want to temporarily go back to an older version of A, so I stashed local changes in A and B, then git checkout 0ec21a1 我想暂时回到旧版本的A,所以在A和B中隐藏了本地更改,然后git checkout 0ec21a1

But Im still on the latest version of the submodule. 但是我仍然在最新版本的子模块上。 I expected the submodule to updated according to the parent version. 我希望子模块根据父版本进行更新。 My understanding from this question, submodule tag is that git does not manage submodules when you checkout the parent, is this correct? 从这个问题我对子模块标签的理解是,在签出父级时git不管理子模块,这是正确的吗?

My real commit history is more complicated and there are several submodules. 我的实际提交历史更加复杂,并且有几个子模块。 Is there a way to determine what version of submodule B was used in commit xxx of A? 有没有办法确定在A的提交xxx中使用了哪个版本的子模块B? I can get approximate versions by comparing the git logs but it's rather painful... 我可以通过比较git日志来获得大概的版本,但这很痛苦。

git checkout 0ec21a1 --recurse-submodules将根据存储在父项目A中的提交更新子模块B的内容(如果已经初始化)(在这种情况下,将检出e79fea0

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

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