git blame: correct author after merge

人盡茶涼 提交于 2019-12-10 02:19:11

问题


A GIT merge introduces a new commit. This causes problems with "git blame": the merged lines appear to be committed by the developer that did the merge.

I can understand this being the case for conflicting changes (because he solved the conflicts). But is there a way to not have this happening for non-conflicting lines? Some option to "git blame"?

If there is no way around, this would basically make "git blame" almost useless when you have a lot of merges - and GIT encourages a lot of merges.

Does SVN have this issue with non-conflicting merges? I don't think so, but I may be wrong as I (understandingly) avoided branches like plague when working with SVN.


回答1:


Internally git blame uses git rev-list to create the revision list. And git rev-list accepts the --no-merges option.

So you can do:

git blame --no-merges <file>



回答2:


I just tried a merge with git version 2.3.8 and the non merge conflicted lines were not attributed to the merge commit author, they are attributed to the original author. Perhaps this has been addressed since your version of git.



来源:https://stackoverflow.com/questions/15769298/git-blame-correct-author-after-merge

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