Git Your Differences Settled

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 MacOS.

screenshot of the command line displaying a merge conflict
uggggggh 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:

sudo xcode-select -switch /Applications/
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.