21

Say I run git pull and there is a conflict that git cannot automatically merge.

After I manually merge the changes, and run git commit, should I leave the Conflicts: section that git generates in the commit (as a record that those files were manually merged), or removed it (as the conflict is not being committed)?

I'm never sure what best practice is - is the warning there to make sure you fix the conflicts, or to be actually logged in the commit message?

nfm
  • 19,689
  • 15
  • 60
  • 90

2 Answers2

21

This seems like a personal opinion type of question, so I'll answer with my opinion [-;

I leave the Conflicts section alone as a reminder down the road that this merge produced conflicts. Occasionally I don't handle the conflicts appropriately, and it will produce some undesired effect later, so it's nice to be able to look through the commit history and see that there was a conflict in a file.

jaredonline
  • 2,912
  • 2
  • 17
  • 24
  • 1
    I always assumed that's why git puts that in the commit message. I would tend to agree with you. Most of the time, you're only looking through lists of `git log --oneline` or whatnot so they don't provide much distraction if you're not looking for them. – Tyler Mar 24 '11 at 04:53
  • 6
    Not only do I leave that list, but if the conflicts were nontrivial, I often add an explanation of what caused the conflicts and how they were resolved. That can be very helpful down the line sometimes. If there are dozens of files with the same kind of conflict, I do often collapse the list down, though. – Cascabel Mar 24 '11 at 05:35
3

I think the best practice is to always describe why you're doing the commit. When merging conflicts, I'd state that you're merging conflicts. But I don't think it's critical to list exactly what all the conflicts are. Always think in terms of re-reading it 2 years from now: what is it you'd want to read about what you're committing. This is good general advice, whether it's about conflicts or just features or bug fixes.

Wes Hardaker
  • 21,735
  • 2
  • 38
  • 69