Reputation: 1892
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.
Upvotes: 5
Views: 3423
Reputation: 11966
As sehe and void.pointer suggested, use:
git blame --no-merges
It's documented on rev-list options:
--no-merges
Do not print commits with more than one parent. This is exactly the same as
--max-parents=1
.
Upvotes: 0
Reputation: 33093
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
.
Upvotes: 0
Reputation: 311735
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.
Upvotes: 3