git log range排除多个基本引用的祖先 [英] git log range exclude ancestors of multiple base refs

查看:107
本文介绍了git log range排除多个基本引用的祖先的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我经常使用git log <options> BASE..TARGET来显示一系列提交.

I often use git log <options> BASE..TARGET to show a range of commits.

根据我以前的经验和理解,这样做是什么

What this does, based on my previous experience and understanding:

  • 包括TARGET及其所有祖先.
  • 排除BASE及其所有祖先,即使它们是TARGET的祖先.

有时候我想实现以下目标:

Sometimes I would like to achieve the following instead:

  • 包括TARGET及其所有祖先.
  • 排除BASE_0及其所有祖先,即使它们是TARGET的祖先.
  • 排除BASE_1及其所有祖先,即使它们是TARGET的祖先.
  • 排除BASE_2及其所有祖先,即使它们是TARGET的祖先.
  • ...

一个典型的用例是查找位于给定功能分支的祖先(但祖先)但既不在master也不在其他特定功能分支中的提交.

A typical use case would be to find commits that are in (= ancestors of) a given feature branch, but are neither in (= ancestors of) master nor a specific other feature branch.

很显然,范围A..B语法在这里不会删减.相反,需要有一个像--exclude-ancestors-of=A_0,A_1,A_2这样的参数,其语法允许多个引用.

Obviously, the range A..B syntax won't cut it here. Instead, there would need to be a parameter like --exclude-ancestors-of=A_0,A_1,A_2, with a syntax that allows multiple refs.

这有可能吗?

推荐答案

作为

As jthill commented, you can express this with:

git log TARGET ^BASE_0 ^BASE_1 ^BASE_2

(这些可以按任何顺序进行).如果您有很多否定引用(上面的^BASE_number表达式是否定引用),则可以使用以下命令简化输入:

(these can go in any order). If you have a lot of negated references—the ^BASE_number expressions above are negated references—you can simplify typing a bit with:

git log TARGET --not BASE_0 BASE_1 BASE_2

--not告诉Git 所有随后的说明符都将被否定.第二个--not否定该否定,回到正引用,所以您可以-对于本示例而言,毫无意义-写:

The --not tells Git all subsequent specifiers are to be negated. A second --not negates the negation, going back to positive references, so you can—a bit pointlessly for this example—write:

git log --not BASE_0 BASE_1 BASE_2 --not TARGET

也是.

在Git中有许多种方式来表示修订版本和修订范围;有关合理完整的列表,请参见 gitrevisions文档(或git help revisions).请注意,尽管在两个命令中,两点和三点语法可能具有不同的含义. git diff命令是最重要的示例.请查阅每个特定的Git命令的手册页,以了解该命令是否对该命令具有特殊含义,如果有,则意味着什么.

There are many ways to express revisions and revision ranges in Git; see the gitrevisions documentation (or git help revisions) for a reasonably complete list. Note that the two-dot and three-dot syntaxes may take on different meanings in several commands, though. The git diff command is the most significant example of this. Consult each specific Git command's manual page to see if it has special meaning to that command, and if so, what the meaning is.

这篇关于git log range排除多个基本引用的祖先的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆