What is a trivial merge in git?

痴心易碎 提交于 2019-12-10 01:36:48

问题


Sometimes when I do a pull instead of a rebase after a simple one file change commit I see the following in the master log:

Trivial merge

But there's no diff of what changed? What's the point of this log message? Did anything change I don't know of? It scares me.


回答1:


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.




回答2:


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)




回答3:


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



来源:https://stackoverflow.com/questions/1824264/what-is-a-trivial-merge-in-git

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