gpt4 book ai didi

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

转载 作者:太空狗 更新时间:2023-10-29 14:12:04 25 4
gpt4 key购买 nike

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

Foo - sub1 - sub2

我希望看到某个提交应用于每个子模块的提交。是否有捷径可寻?

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

最佳答案

git submodule summary 命令会给你(大部分)你想要的。我要使用 ansible以存储库为例,因为它有几个与之关联的子模块。

pull 一些更新后:

$ 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 命令来获取摘要在当前 checkout 的子模块版本和存储库中的版本:

$ 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 log我们得到了 git submodule summary

关于git - 如何在父存储库的两次提交之间查看应用于子模块的提交?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36500240/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com