我如何在没有看到合并的情况下进行责备

发布于 2024-10-21 17:33:19 字数 323 浏览 4 评论 0原文

如果我有一个文件,其历史记录如下:

----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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

贱贱哒 2024-10-28 17:33:19

实际上,您确实关心D。考虑这种情况:

in commit B:
2) banana
3) coconut
4) domino     // conflicts with C

in commit C:
2) banana
3) coconut
4) elephant   // conflicts with B

在提交D中,我们解决了冲突:

in commit D:
2) banana
3) coconut
4) domino-elephant

注意,在D中,出现了一行在B或C中都没有出现的行。如果您忽略合并,你永远不会看到这一点,而且你永远无法知道第 4 行来自哪里,这很糟糕。

Actually, you do care about D. Consider this case:

in commit B:
2) banana
3) coconut
4) domino     // conflicts with C

in commit C:
2) banana
3) coconut
4) elephant   // conflicts with B

In commit D, we resolve the conflict:

in commit D:
2) banana
3) coconut
4) domino-elephant

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.

℉絮湮 2024-10-28 17:33:19

另一种方法是使用 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 between start and end in filename. You can also use git 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 with git blame in many cases, but I was able to find the "real" (i.e. non-merge) change more conveniently than with git blame.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文