如何在父存储库的两次提交之间查看应用于子模块的提交



假设我有一个包含两个子模块的存储库:

Foo-sub1-sub2

我希望看到通过某个提交将提交应用于每个子模块。有简单的方法吗?

如果我的问题不清楚,在我的用例中,sub1和sub2正在跟踪某个分支的历史,所以如果我要获得Foo的commit1的sub1的提交哈希和Foo的commit2的提交哈希,并在这些提交之间进行git日志,我应该会看到一些中间提交,显示这些提交之间应用的所有更改。我想要所有子模块的信息。

git submodule summary命令将为您提供(大部分)所需内容。我将使用ansible存储库作为一个例子,因为它有几个与之相关的子模块

提取一些更新后:

$ git pull

我可以看到我的子模块现在已经过时了:

$ git status
On branch devel
Your branch is up-to-date with 'origin/devel'.
Changes not staged for commit:
  (use "git add <file>..." to update what will be committed)
  (use "git checkout -- <file>..." to discard changes in working directory)
  modified:   lib/ansible/modules/core (new commits)
  modified:   lib/ansible/modules/extras (new commits)

我可以使用git submodule summary命令来获得在当前签出的子模块的版本和存储库中的版本:

$ git submodule summary lib/ansible/modules/core
* lib/ansible/modules/core 2f46c35...f15000d (46):
  < fix win_user type checking
  < git still needs to have abspath applied to dest
  < Wrap calls to main() with if check
  < handles config replace properly in eos_template
  ...

这显示了每个提交的第一行;如果我想要详细的信息,我可以使用的第一行中显示的提交范围输出(2f46c35...f15000d):

$ git submodule update
$ cd lib/ansible/modules/core
$ git log 2f46c35...f15000d

我们首先更新子模块,使其达到当前提交,然后使用提交范围在该存储库中运行git logCCD_ 5给药。

最新更新