Skip to content

How To Handle Merge Conflicts

thewoolleyman edited this page Nov 20, 2014 · 5 revisions

When you do a merge or rebase, sometimes you get merge conflicts which have to be resolved by hand.

Tip: you can reduce the likelihood of merge conflicts by making sure to keep your branches closely in sync with each other. Commit many times per day and try to rebase your branches together daily. See Git Rebase Workflow for more details

Tools exist to make fixing merge conflicts less painful. After Git tells you there's a merge conflict, you can run git mergetool to launch one of these tools. The default is vimdiff which is really only a viable option if you're already comfortable with vim. If for some crazy reason you are, then great, but you'll probably want to change your merge tool to something else.

Here's how to do that:

$ git config --global merge.tool <name of tool>

Then, to launch yourself into the merge tool, run:

$ git mergetool

There exist some useful GUI tools to help you handle merge conflicts in Git.

Linux: Meld
Mac: SourceTree