简体   繁体   English

在git历史记录中查找未部署的提交

[英]Find not deployed commits in git history

When we are planing a next release, we build the release notes by looking at commits which are not included in the last release. 在计划下一个发行版时,我们通过查看上一个发行版中未包含的提交来构建发行说明。 Normally we use gitk and a trained eye to detect such commits. 通常,我们使用gitk和训练有素的眼睛来检测此类提交。 But now, since the number of commits and branches are increasing, it gets harder and harder to see those. 但是现在,由于提交和分支的数量正在增加,因此越来越难以看到它们。

Is there a command which prints all commits under HEAD but not a specific tag? 是否有一个命令可打印HEAD下的所有提交,但不打印特定标签的命令? To make this more clear I added this over simplified example. 为了更清楚地说明这一点,我在简化示例中添加了此内容。

                    F <- develop | HEAD
                    | \ 
                    D E
                    | |
last_release_tag -> B C
                    |/
                    A 

The expected output would be: CEDF (The order is not important.) 预期的输出为:CEDF(顺序不重要。)

Thanks in advance. 提前致谢。

What you're looking for is a range of commits including everything up to HEAD, but excluding things up to the last release tag. 您要查找的是一系列提交,包括直到HEAD的所有内容,但不包括最新发布标记的内容。 You might use: 您可以使用:

git log last_release_tag..HEAD

which is equivalent to: 等效于:

git log ^last_release_tag HEAD

See "SPECIFYING RANGES" in gitrevisions(7) for more detail. 有关更多详细信息,请参见gitrevisions(7)中的 “指定范围”。 In the second form you can use more than one ^last_release_tag if you need to exclude multiple tags (this might be necessary if eg version C was also released). 在第二种形式中,如果需要排除多个标签,则可以使用多个^last_release_tag (如果还发布了C版本,则可能需要使用)。

You might also want to investigate options like --oneline or the --pretty formats to customise the output, depending on how you want your release notes to look. 您可能还希望研究--oneline--pretty格式之类的选项以自定义输出,具体取决于您希望发行说明的外观。 More detail can be found under "PRETTY FORMATS" in git-log(1) . 可以在git-log(1)的 “ PRETTY FORMATS”下找到更多详细信息。

gitk is just a graphical layer on top of the standard Git tools. gitk只是标准Git工具之上的图形层。 In your example, 在您的示例中

git log last_release_tag..F

would list information about the commits you want. 将列出有关所需提交的信息。 The command should be interpreted as "commits reachable by F except those reachable by the commit that last_release_tag points to". 该命令应解释为“ F可以到达的提交,last_release_tag所指向的提交可以到达的提交”。 There are numerous formatting options if the default output format doesn't suit your needs, see git-log(1) . 如果默认输出格式不符合您的需求,则有很多格式化选项,请参见git-log(1) For details on how revision ranges can be specified see gitrevisions(7) . 有关如何指定修订范围的详细信息,请参见gitrevisions(7)

For scripting purposes where you only want the SHA-1s of the commits, use the git rev-list plumbing command. 为了只需要提交SHA-1的脚本编写目的,请使用git rev-list plumbing命令。

A bash script should do the job: bash脚本应该可以完成以下工作:

for commit in `git log --pretty=format:"%H" START_COMMIT..HEAD; do
  # Is there a tag which points to this commit ?
  tag=`git tag -l --points-at $commit`; 
  # Test if not the specific tag
  if test "$tag" != "specific_tag"; then 
    # You can use any git command on the commit here
    echo $commit;
  fi ; 
done

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

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