Oct 252013

A cool bit of CLI trickery that James Humphrey shared with me. This allows you to use IDEA for diffing and merging via git’s mergetool and difftool commands.

First, add IDEA to your path (everything is in Mac-speak here):



Next, add these lines to your ~/.gitconfig file:

That’s it. Now you can use IDEA to diff and merge from git CLI like this:

  8 Responses to “Using IDEA for Git merging and diffing”

  1. Great, thanks for the tip. I think in the Bash config you may want to set PATH=$INTELLIJ_HOME $PATH

  2. Hi. Do you have an example of how to setup idea for merging and diffing on windows?

  3. Unfortunately does not work with PyCharm CE as of now, even though it’s linked in the docs :\

  4. If you’re having trouble getting this to work in MacOS/Linux (in particular, if invoking git diff/merge fails to bring up the IDEA diff/merge window), please note that JetBrains recommends creating a command-line launcher (Tools | Create Command-line Launcher) instead of putting the idea binary on your PATH directly: https://www.jetbrains.com/help/idea/running-intellij-idea-as-a-diff-or-merge-command-line-tool.html

    See also: https://youtrack.jetbrains.com/issue/IDEA-183500

  5. This doesn’t work if idea is opened already. As command exits instantly, and files got deleted after that, Idea has not files to compare.

  6. If there are multiple files which need to be merged when you run git mergetool it seems like only the first file gets opened properly in IntelliJ. After that I get errors about unable to find LOCAL file.

    • That’s strange. I wonder what Git is sending as parameters. That’s probably either an IJ bug of not handling multiple files passed in, or a git issue where it isn’t spawning the sub-process multiple times correctly. I’ll have to play around with it and see what is going on. Let me know if you figure it out.

 Leave a Reply

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code class="" title="" data-url=""> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong> <pre class="" title="" data-url=""> <span class="" title="" data-url="">



This site uses Akismet to reduce spam. Learn how your comment data is processed.