How can I blame git without seeing a merge

If I have a file whose history is as follows:

----A----B \ \ C----D----E 

and I'm to blame for E, then I would like to see what has changed in versions B and C, but I'm really not interested in D, since it was a merge.

Is there a way I can do this? I suppose I'm looking for some kind of -no-merges option for git guilt, but I don't see it in manual .

+4
source share
2 answers

Actually, you 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 

Note that a line appears in D that does not appear in either B or C. If you ignore the merge, you will never see this, and you will never be able to determine where line 4 came from, bad.

+4
source

An alternative is to use git log -L start,end:filename which displays the (by default full) 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 strings by regular expression rather than line numbers. By nature, you are likely to get results other than git blame in many cases, but I managed to find a β€œreal” (i.e. not merging) change more convenient than with git blame .

0
source

Source: https://habr.com/ru/post/1343533/


All Articles