How do I git blame without seeing merges

2019-05-08 16:17发布

问题:

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.

回答1:

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.



标签: git blame