Katipo
Search  
Site Blog
  About  
  Home
About Portfolio Solutions Client Area Contact Us
: : About Us
Awards
Jobs
Our People
What Is A ... ?
Working From Home
News
Photo Gallery
Katipo Blog


Resolving conflicts with git on Mac OS X

I 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):

$ git pull kete_master master

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):

git config –global merge.tool opendiff

Then from the shell run this:

$ git mergetool

And then you should see output something like this:

Merging the files: app/views/layouts/application.rhtml

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.

Leave a Reply

You must be logged in to post a comment.


Katipo
Rachel Snowboarding