Describing my Merge Conflict Resolution

I couldn’t see a thread for describing the Merge Conflict Resolutions from Lecture 20, so I started this one.

  • Following along with Ben’s lectures (and learning the tiniest bit of Unity 3D into the bargain) I was messing about with a ground plane, a red box and a couple of materials when along came a snowman, albeit it with no arms.

  • I considered it prudent to branch my project at this point as I wasn’t sure that the snowman was really the direction to go in, sunny day, green grass and all.

  • As you can see, I added some a body, a head and the ubiquitous black hat to the snowman, dutifully saving in Unity and making commits as I went along.

  • It was at this time, unbeknown to me, that it all started to go wrong. In retrospect, it was, of course, all Ben’s fault. He was making this shiny red sports car out of a cube and some cylinders and I thought “Maaaan, I want one of those”. The next thing I knew, I was back in the master branch, knocking out my own red sports car, saving the project as I tweaked it, and making commits without a care in the world.

  • Pleased with the car, I merged that into the Master, made another couple of mods and committed them.

  • Somewhere along the way I realised that I did want the snowman after all. But wait… he’s in a branch in a scene called “SampleScene” and the car is in the master in a scene also called “SampleScene”. < sigh > If I go ahead and merge the branch, it’s not going to end well for one of them.

Here is what I did:

  • When the Merge dialogue came up with the conflict error: stashed the uncommitted changes it showed. (This was necessary before switching branches.)

  • Checked out the snowman branch and opened it in Unity. Duplicated the scene, named it snowman, saved it and committed.

  • Checked out the the master branch. Right clicked the snowman branch and chose the option to merge it into the current branch.

  • Read, absorbed and dismissed the error messages.

  • Clicked on the uncommitted changes at the top of the History.

  • In the Staged Files pane: right clicked on the file name with the orange warning trianlge and chose “Resolve Conflicts -> Resolve Using Mine” from the menu and clicked OK on the confirmation dialogue.

  • Committed the changes.

  • Back in Unity I now have “SampleScene” with my shiny red sports car AND “Snowman” with my bowler hatted, but armless snowman.

  • Finally, I removed the PT-snowman branch altogether.

The moral of this story? Don’t be distracted by the shiny. Red sports cars are often trouble*.

I’m not sure this will really be much help to anyone else, it’s little more than a description of me working through the lecture. But, it was very useful for me. I did it the first time following along with Ben and it seemed oh so easy. When I tried to recreate it on my own, making notes as I went, it took me four goes to get it right. So if nothing else, this will be printed and pasted into my logbook as a reference for me, for next time :c)

*The last one I had was a LOT of trouble.

1 Like

My merge conflict resolution was simulating a situation where two people were assigned to prototype different colors for the car:

  1. Two Branches were created: bluecar and redcar
  2. Bluecar was merged into master before a real decision was made about the car color.
  3. The boss wanted the car red, so I then tried to merge the redcar, and now we have a merge conflict.
  4. I chose to keep “theirs” which is the redcar and successfully resolved the merge conflict.