[英]Git display diff of all unmerged changes in branch
I want to delete some old branches that I have locally, but not before I make sure that the changes in those branches are not changes I want to keep.我想删除我在本地拥有的一些旧分支,但在我确定这些分支中的更改不是我想要保留的更改之前。
Correct me if I'm wrong, but I thought that a good way to do that would be to check if it contains anything that has not been added to the master branch yet.如果我错了,请纠正我,但我认为这样做的一个好方法是检查它是否包含尚未添加到 master 分支的任何内容。 So I'd like to display those changes.
所以我想显示这些更改。
Note that I don't want to merely do请注意,我不想仅仅做
git diff master..old_branch
because I would get a lot of noise, consisting of all the changes that were added to master since then.因为我会得到很多噪音,包括从那时起添加到 master 的所有更改。
I also don't think I want我也不认为我想要
git diff master...old_branch
because, from what I undersand, it just displays the commits that were added to old_branch after it derived from master, but does not check if those commits were added (cherry-picked, for instance) to master later on.因为,据我所知,它只显示从 master 派生后添加到 old_branch 的提交,但不检查这些提交是否已添加(例如,樱桃挑选)到 master 以后。
How do I do that ?我怎么做 ?
edit: Let me try to rephrase my question, since there seems to be some confusion.编辑:让我试着重新表述我的问题,因为似乎有些混乱。 I don't just want to see commit differences, but rather all lines that have been added by old_branch since it was created from master, but without displaying those that have since been added on the master branch.
我不仅想查看提交差异,还想查看自 old_branch 从 master 创建以来添加的所有行,但不显示此后添加到 master 分支上的行。
So for example:例如:
In this case I would want to show the 'ef', since 'def' was added by old_branch, but 'd' was also added in the master branch, and 'g' has been added only by the master branch, so the changes that are in old_branch and not merged in master is 'ef'.在这种情况下,我想显示 'ef',因为 'def' 是由 old_branch 添加的,但 'd' 也被添加到主分支中,而 'g' 仅由主分支添加,因此更改在 old_branch 中且未合并到 master 中的是“ef”。
edit2: To put it in yet another perspective:编辑2:换个角度来看:
Let's name D
the commit where master
and old_branch
diverged (ie their common root, or ie where the old_branch
was created)让我们将
master
和old_branch
分歧的提交命名为D
(即它们的共同根,或者即创建old_branch
地方)
Then I want diff(old_branch, D) - diff(master, D)
然后我想要
diff(old_branch, D) - diff(master, D)
which means that I want all differences between old_branch
and D
, but I want to disgard all changes that differ from old_branch
to D
if they also differ from master
to D
.这意味着我想要
old_branch
和D
之间的所有差异,但我想忽略从old_branch
到D
所有变化,如果它们也从master
到D
不同。
Thanks谢谢
If you want to see any changes in branch old_branch
that are not currently in master
your first command is almost correct:如果您想查看当前不在
master
中的分支old_branch
中的任何更改,您的第一个命令几乎是正确的:
git diff old_branch..master
Note the two dots vs. three.请注意两个点与三个点。 Also note
old_branch
comes first in the statement.还要注意
old_branch
在语句中old_branch
在第一位。 If you reverse the order, you'll get a reverse diff of changes in master
not in old_branch
.如果您颠倒顺序,您将获得
master
而不是old_branch
中更改的反向差异。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.