How the git mergetool solved my anxiety, fears, and most importantly, my merge conflicts

Back in March, another student fellow Nicole Zhu and I worked on a team challenge for which we were the primary coders. One day, she emailed me:

“Uhh. I messed up. Sorry. I think you have to delete your repo.”

She had been attempting to resolve a merge conflict, ended up in vim somehow, nope’d out of there, and messaged me to let me know her solution was to delete everything and re-clone.

More sadly, I completely empathized with her active avoidance of figuring out how to actually resolve the merge conflict because I didn’t know what was happening either.

We know how this story ends. We tried to avoid merge conflicts like bad news, but when Nicole and I started working on Romaine together as its primary coders, we decided we could no longer suffer its intimidation like battered warriors of a mythical enemy.

But I say a mythical enemy, because as it turns out, resolving merge conflicts isn’t as scary as all those tutorials out there make it seem. Yes, you’ll have to witness some alarming red lines flash across your screen on your command line. Yes, it will feel painful, accepting your ill fate, but only for a little bit.

Because there’s this thing called the git mergetool, and it’s kind of like the magic wand everybody forgot to tell you existed (everybody, except Joe Germuska).

Let me explain.

1

Uh oh. This is an impending merge conflict. We know this because:

error: failed to push some refs to ‘git@github.com:suyeonson/merge_conflict.git’

This indicates there are some changes on my remote branch that would conflict with the changes I’m trying to push from my local files.

All right, fine. Let’s pull those changes first.

2

There’s that merge conflict.

CONFLICT (content): Merge conflict in index.html

Now, instead of digging through your files to find those pesky >>> and === signs that indicate where you should be looking, type:

git mergetool

This might lead you to this message:

3

Lucky for me, opendiff is my default merge resolution tool here even though I have not configured my mergetool. But if you’re like Nicole, where your computer decides that of all things, vimdiff (a resolution tool using the godforsaken vim -- you know, the thing you can never figure out how to navigate), type:

git config --global merge.tool opendiff

git mergetool -y

This configures your global git settings to make your default merge tool opendiff, then gives your computer the go ahead to use it.

What this launches is a GUI that looks something like this:

4

Each little bubble indicates where there is a difference between the two files, where the left pane is your local file and the right pane is the remote file with someone else’s changes. Using your arrow keys, you can indicate which pane’s difference/change you would like to keep.

See that dot in the lower middle of the pane? Drag it up, for your sanity:

5

And now you’ve got a third pane, which is the final version of your file, given the changes you’ve decided to keep or toss (here, I’ve decided to go with all of the remote file’s changes. Yes, I know that’s broken code.)

When you’ve looked over that third pane, simply save (command + s) as you would a document.

Boom. You’re done.

“Merge conflicts threw a wrench in my understanding of GitHub,” Zhu said. “Collaboration is a key component of GitHub and it was annoying that I didn’t know how to take advantage of that collaborative aspect. In the real world, you can’t just delete a repo and start over.”

Lucky for us, we got through this ordeal together. The curse of unknowledge and fear has been lifted.

About the author

Suyeon Son

Undergraduate Fellow

Latest Posts

  • With the 25th CAR Conference upon us, let’s recall the first oneWhen the Web was young, data journalism pioneers gathered in Raleigh

    For a few days in October 1993, if you were interested in journalism and technology, Raleigh, North Carolina was the place you had to be. The first Computer-Assisted Reporting Conference offered by Investigative Reporters & Editors brought more than 400 journalists to Raleigh for 3½ days of panels, demos and hands-on lessons in how to use computers to find stories in data. That seminal event will be commemorated this week at the 25th CAR Conference, which...

    Continue Reading

  • Prototyping Augmented Reality

    Something that really frustrates me is that, while I’m excited about the potential AR has for storytelling, I don’t feel like I have really great AR experiences that I can point people to. We know that AR is great for taking a selfie with a Pikachu and it’s pretty good at measuring spaces (as long as your room is really well lit and your phone is fully charged) but beyond that, we’re really still figuring...

    Continue Reading

  • Capturing the Soundfield: Recording Ambisonics for VR

    When building experiences in virtual reality we’re confronted with the challenge of mimicking how sounds hit us in the real world from all directions. One useful tool for us to attempt this mimicry is called a soundfield microphone. We tested one of these microphones to explore how audio plays into building immersive experiences for virtual reality. Approaching ambisonics with the soundfield microphone has become popular in development for VR particularly for 360 videos. With it,...

    Continue Reading

  • Prototyping Spatial Audio for Movement Art

    One of Oscillations’ technical goals for this quarter’s Knight Lab Studio class was an exploration of spatial audio. Spatial audio is sound that exists in three dimensions. It is a perfect complement to 360 video, because sound sources can be localized to certain parts of the video. Oscillations is especially interested in using spatial audio to enhance the neuroscientific principles of audiovisual synchrony that they aim to emphasize in their productions. Existing work in spatial......

    Continue Reading

  • Oscillations Audience Engagement Research Findings

    During the Winter 2018 quarter, the Oscillations Knight Lab team was tasked in exploring the question: what constitutes an engaging live movement arts performance for audiences? Oscillations’ Chief Technology Officer, Ilya Fomin, told the team at quarter’s start that the startup aims to create performing arts experiences that are “better than reality.” In response, our team spent the quarter seeking to understand what is reality with qualitative research. Three members of the team interviewed more......

    Continue Reading

  • How to translate live-spoken human words into computer “truth”

    Our Knight Lab team spent three months in Winter 2018 exploring how to combine various technologies to capture, interpret, and fact check live broadcasts from television news stations, using Amazon’s Alexa personal assistant device as a low-friction way to initiate the process. The ultimate goal was to build an Alexa skill that could be its own form of live, automated fact-checking: cross-referencing a statement from a politician or otherwise newsworthy figure against previously fact-checked statements......

    Continue Reading

Storytelling Tools

We build easy-to-use tools that can help you tell better stories.

View More