When using git, I much prefer using the command line as opposed to any GUI applications. However, a problem arises when merging conflicts between the local branch and the remote. Looking at the file and doing it manually can be quite a chore, and the syntax to show which edit is from where is confusing for me. The only other option is Git’s default tool for merging, called vimdiff. It’s basically just running the vim editor with a +diff feature. That might be perfect for vim users, but I have no desire to learn the slew of shortcuts I’d need just for this one type of situation.

Welcome Meld to the picture. Here’s the description from the program’s site:

“Meld is a visual diff and merge tool targeted at developers. Meld helps you compare files, directories, and version controlled projects. It provides two- and three-way comparison of both files and directories, and has support for many popular version control systems.”

Here’s the rundown:

Pop open your trusty terminal and run

Now, to replace vimdiff with this lovely GUI, enter

After realizing there’s a conflict and using git pull  to grab the remote’s changes, it’s time to merge the conflicts, commit, and then push your altered file.

It’s as easy as entering  git mergetool . Follow that by hitting enter to confirm, and Meld will launch.

meld-gitmerge-example

Meld in action

The middle field will be your new file after merging the changes. Simply click the arrows to move the desired lines into your new document. You can also manually type or copy/paste into the middle if manual tweaking is needed. Click save, close Merge, and you’re done. Meld will make a backup copy of your local branch’s version, so just delete it when you’re done if you don’t need it anymore. Commit your changes and push to your remote. Conflicts merged and ready for more coding.