Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to check if a merge commit contains manual changes (e.g. resolved conflicts)?

How can I find out if there were conflicts when merging a branch and what shenanigans did the person have to do to resolve those conflicts?

git log -p seems to show empty diffs for all merge commits, regardless whether they have manual changes or not.

like image 678
Eugene Yarmash Avatar asked Jul 22 '17 10:07

Eugene Yarmash


People also ask

How do you check if there is merge conflict?

To see the beginning of the merge conflict in your file, search the file for the conflict marker <<<<<<< . When you open the file in your text editor, you'll see the changes from the HEAD or base branch after the line <<<<<<< HEAD .

How do you check if a commit is a merge commit?

1 answer. You just need to check the length of the `parents`. If there are two or more commits, it's a merge commit, otherwise it's a regular commit.


1 Answers

git show produces a combined diff for a merge commit by default, which will contain only the lines that changed as part of the conflict resolution.

git show <merge_commit_sha1>

git log takes the --cc option to produce combined diffs for merge commits. For example, to find all merge commits with manual changes you can use:

git log -p --cc --min-parents=2

and look for commits with diffs.

like image 182
Eugene Yarmash Avatar answered Oct 15 '22 16:10

Eugene Yarmash