What is a trivial merge in git?

浪子不回头ぞ 提交于 2019-12-05 00:56:47

git doesn't insert this message into the log at any point. I'm going to take a wild guess and assume that you've seen this message in gitweb.

gitweb prints this message if there is no output from a combined diff. This happens when the only differences were all in chunks were only one side of the merge changed, and this change was brought through unmodified in the merge. This basically means there were no conflicts and nothing magic was added in the merge commit.

I confirm the only place in git codebase where the message "Trivial Merge" is displayed is in gitweb.perl, in the git_patchset_body() function (right here):

if ($patch_number == 0) {
    if (@hash_parents > 1) {
        print "<div class=\"diff nodifferences\">Trivial merge</div>\n";
    } else {
        print "<div class=\"diff nodifferences\">No differences found</div>\n";
    }
}

The document (included in Git documentation) trivial-merge.txt does explain in detail all the cases which result in a "trivial merge" (and they were discussed in this thread)

git merge's help page (the one you get by typing "git help merge") states:

you received the same patch from an external source to produce the same result as what you are merging

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