Git your differences settled

Published on: 2017-03-17

Written by: Jason Land

Dealing with git merge conflicts and trying to figure out which side of ======== was the new code vs old code is a huge pain the ass. So big, that I'm sure it's not just me that dislikes dealing with it. There's a solution and it's so much better that I don't know why it's not more widely known, especially since so many developers work on OSX.

Ugggh why?

The solution

Make sure you have XCode installed. It's in the desktop App Store. It does require your version of MacOS be up-to-date.

Then copy these lines into your Terminal/iTerm2:

sudo xcode-select -switch /Applications/Xcode.app/Contents/Developer
git config --global merge.tool opendiff

That's it.

How to use it

When you git pull and have a merge conflict show up, you can now run

git mergetool

and a FileDiff window will pop up, showing you how your code looks in the different versions. You can cycle between blocks of changed code with the up/down arrows, and use the left/right arrows to select which version you want to merge into your commit.

Back to the blog

previous post |

blog comments powered by Disqus