I was introduced to the horrors of merging by the Concurrent Version System, or CVS, back around 1995 or so. The source control systems I had used before then, sccs and rcs, worked on the principle that in order to update a file, a single individual locked it. No one else could work on the file until the changes were checked in or the lock cancelled.
And resolving update conflict using CVS was hideous. It seemed to blindside you: you had made your changes, the modified code was working, but just as you were tidying up and looking forward to the next task, you had to solve the problem of fitting your mods into a file that someone else had gotten to before you.
Over the years, version control systems have become much better at making smart merge decisions without human intervention. But update conflicts still occur, and merging is still a great pain.
The way to minimize this pain is well-known: beat the other guys to the punch. If your changes don’t break the build or break functionality, get them in first, and let someone else worry about merging his or her changes. With this strategy, even if you have to resolve a clash, the differences are likely to be small, and the work you did will be fresh on your mind. An added benefit to frequent merges is that if someone reviews your code, he or she will have a much easier time following your work if the deltas are smell.
At every software shop, however, you will find coders who hate merging even more than I do, who hate merging so much that they won’t do it until forced by their manager.
This is one of those cases in which ineffective avoidance behavior just makes things much worse — not unlike a deer staying frozen in the headlights rather than jumping out of the way.
When the coder who has refused to merge is finally forced to do so, there are likely to be many clashes. Resolving clashes is much more difficult, and much more destabilizing to the code. It is not unusual updates by others to wind up inadvertently backed out by mistake.
That’s why I say merging is the second worse thing. The worse thing, worse even than merging, is having your fix or feature deleted by some nimrod who would not merge his code frequently.
Don’t be that guy.