How do I git blame without seeing merges

我只是一个虾纸丫 提交于 2019-12-05 13:51:38

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.

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.

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!