Resolving conflicts with git on Mac OS X
Friday, August 29th, 2008I just had to resolve my first conflict in git. It’s a little more convoluted than with subversion, but slicker overall.
So you run into a conflict during a merge (implied by this git pull command):
…
Auto-merged app/helpers/application_helper.rb
Auto-merged app/views/layouts/application.rhtml
CONFLICT (content): Merge conflict in app/views/layouts/application.rhtml
…
Automatic merge failed; fix conflicts and then commit the result.
First up, you need to have your git config point at opendiff on Mac OS X. Do the following if you haven’t already (you only have to do this once and it will be set permanently):
Then from the shell run this:
And then you should see output something like this:
Normal merge conflict for ‘app/views/layouts/application.rhtml’:
{local}: modified
{remote}: modified
Hit return to start merge resolution tool (opendiff):
Hit return and the OpenDiff application should startup with the conflicted file. It will have side by side comparisons of local version of the file and the remote version of the file with nifty highlighted areas where things are different. Select the first highlighted region, go down to the bottom right and choose the appropriate side in the “Action” menu, then proceed on to the next one, and so on until you have taken care of all differences. Then click File > Save Merge.
Back on the shell you are ready to do commit your resolved file. Do “git commit” and you enter an editor to put in your commit message.
Move on to other tasks, you’re done.

