问题描述
假设我的存储库中有两个版本,每个版本的标签如下:
Suppose I have two versions in my repository... each has been tagged as follows:
- Tag1
- Tag2
现在假设提交更新了子模块引用,以指向Tag1和Tag2之间的新子模块提交.我运行以下命令,并得到以下信息:
Now suppose that a commit updated a submodule reference to point to a new submodule commit between Tag1 and Tag2. I run the following command, and get this:
# show commits between these two tags
git log Tag1..Tag2
commit be3d0357b93322f472e8f03285cb3e1e0592eabd
Author: James Johnston <snip>
Date: Wed Jan 25 19:42:56 2012 +0000
Updated submodule references.
在这种情况下,唯一的更改是子模块的更新.如何获得与父存储库提交交错的子模块提交?
In this case, the only change was an update of the submodule. How do I get the submodule commits to be interleaved with the parent repository commits?
具体地说,在此示例中,假设父存储库指向子模块中的SubTag5标记.子模块中稍后的两个提交是SubTag6标记.显示的提交将子模块指针更新为指向SubTag6而不是SubTag5.我想做的是拥有git log
,除了已经打印的提交外,还要打印两个子模块的提交,这将子模块从SubTag5转移到SubTag6.
Specifically, in this example, suppose that the parent repository points to the SubTag5 tag in the submodule. Two commits later in the submodule is a SubTag6 tag. The commit shown updated the submodule pointer to point to SubTag6 instead of SubTag5. What I would like to do is have git log
, in addition to the commit it already printed, print the two submodule commits as well that brought the submodule from SubTag5 to SubTag6.
推荐答案
这是一个简单的bash命令,它创建一个ASCII提交图(类似于gitk),当超级项目中的某个子模块被更改时,该图会交织相关的子模块提交.它会为每次提交打印出完整的补丁程序,然后使用grep过滤出补丁程序内容,仅保留摘要行和子模块更改.
Here's a simple bash command that creates an ASCII commit graph (similar to gitk) that interleaves the relevant submodule commits when a submodule gets changed in the superproject. It prints out the full patch for every commit and then uses grep to filter out the patch contents leaving only the summary lines and submodule changes.
git log --graph --oneline -U0 --submodule Tag1..Tag2 | grep -E '^[*| /\\]+([0-9a-f]{7} |Submodule |> |$)'
它产生类似于以下内容的输出:
It produces output similar to this:
* 854407e Update submodule
| Submodule SUB 8ebf7c8..521fc49:
| > Commit C
* 99df57c Commit B
* 79e4075 Commit A
这篇关于在子模块提交消息中包含"git log"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!