[英]Git rev-list: exclude commits already included in a merge
I have a repository with a master branch that has frequent merges from different defect branches, like in the picture below (defect1 is the name of the defect branch): 我有一个带有master分支的存储库,该分支具有来自不同缺陷分支的频繁合并,如下图所示(defect1是缺陷分支的名称):
I would like to retrieve a list of all the commits of the master branch, from the one previous to commit A up until the head (in this case, E). 我想检索master分支的所有提交的列表,从先前提交A直到头(在这种情况下为E)的列表。 This list will be used to revert all the commits due to a specific use case of my project.
由于我的项目的特定用例,此列表将用于还原所有提交。
I've been gathering this list by using git rev-list
: 我一直在使用
git rev-list
收集此git rev-list
:
git rev-list "${commitA}~1"..origin/master
The problem is that when I do that, I get commits X and Y in the mix, while commit D already includes the changes of both commits X and Y. I can revert commit D with git revert -m 1
. 问题是当我这样做时,我得到了混合的提交X和Y,而提交D已经包含了提交X和Y的更改。我可以使用
git revert -m 1
来还原提交D。 When I try to revert X and YI get an error, since the commits are not in the master tree. 当我尝试还原X和Y时,由于提交不在主树中,因此出现错误。 I would like to retrieve A~1, A, B, C, D and E only.
我只想检索A〜1,A,B,C,D和E。 I could easily do something like:
我可以轻松地执行以下操作:
git rev-list "${commitA}~1"..origin/master ^defect1
but there can be multiple defect branches with different names and it's impossible to know their names in advance. 但是可能存在多个名称不同的缺陷分支,并且不可能事先知道它们的名称。
Are there other options within git-rev-list that can enable this behavior? git-rev-list中是否有其他选项可以启用此行为?
git rev-list master --first-parent
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.