1

Whenever I use git cherry-pick and there are conflicts, after resolving the conflicts and running git cherry-pick --continue, the commit message has an added Conflicts: section, like so:

<The original commit message>

Conflicts:
    <path of first file that had a conflict>
    ...
    <path of last file that had a conflict>

# The usual comment with instructions

The Conflicts: section is not commented out, so if left unchanged, it becomes a part of the actual commit message of the cherry-picked commit.

So, two questions about this:

  1. Why is this section useful at all? If I resolved the conflicts, why is the fact that they existed relevant?

  2. Is there a way to disable this behaviour? I find it annoying to have to delete that section manually every time.

EDIT: Since a comment suggests that the behaviour may be dependent on the version of git: I'm using git 2.1.4, which is the version present in Debian stable's repositories.

HighCommander4
  • 50,428
  • 24
  • 122
  • 194
  • 2
    A newer version of Git puts these lines in the comment section so they won't be part of the message. These lines record which files have conflicts. It might be useful when one wants to know what happened during the merge. – ElpieKay Jan 25 '17 at 05:27

1 Answers1

1

For your questions:

  1. It mainly caused there still have conflicts. You can use git status to check. If there have conflicts, you should modify and save the conflict files, then use git add . and git commit. Also you can update git to latest version.

  2. Yes, you can use -X to solve the conflicts automatically. Such as git cherry-pick SHA -X [ours|theirs]. ours means to keep changes from current branch, theirs means keep changes from the SHA.

Marina Liu
  • 36,876
  • 5
  • 61
  • 74