我如何在没有看到合并的情况下进行责备
如果我有一个文件,其历史记录如下:
----A----B
\ \
C----D----E
并且我对 E 进行了责备,那么我想看看修订版 B 和 B 中发生了什么变化。 C,但我并不真正关心 D,因为那是合并。
我有办法做到这一点吗?我想我正在寻找某种 --no-merges 选项来 gitblame,但我没有在 手册。
If I've got a file whose history is like this:
----A----B
\ \
C----D----E
and I do a blame from E then I'd like to see what changed in revisions B & C, but I don't really care about D, since that was a merge.
Is there a way I can do this? I guess I'm looking for some kind of --no-merges option to git blame, but I'm not seeing one in the manual.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
实际上,您确实关心D。考虑这种情况:
在提交D中,我们解决了冲突:
注意,在D中,出现了一行在B或C中都没有出现的行。如果您忽略合并,你永远不会看到这一点,而且你永远无法知道第 4 行来自哪里,这很糟糕。
Actually, you do care about D. Consider this case:
In commit D, we resolve the conflict:
Notice that in D, a line appears which didn't appear in either B or C. If you ignore merges, you would never see that, and you'd never be able to tell where line 4 came from, which is bad.
另一种方法是使用 git log -L start,end:filename ,它显示(默认情况下完整的)在
start
和之间编号的行的历史记录在
。您还可以使用 git log -L /regex/,/regexend/:filename 来通过正则表达式而不是行号来识别行。就其本质而言,在许多情况下,您可能会得到与使用 gitblame 不同的结果,但我能够比使用 gitblame 更方便地找到“真实”(即非合并)更改。文件名
中结束An alternative is to use
git log -L start,end:filename
which shows (by default, the complete) history of the line or lines numbered betweenstart
andend
infilename
. You can also usegit log -L /regex/,/regexend/:filename
to identify lines by a regex instead of by line numbers. By its nature you will probably get different results than withgit blame
in many cases, but I was able to find the "real" (i.e. non-merge) change more conveniently than withgit blame
.