IntelliJ IDEA 14.0.0 Web Help

Running IntelliJ IDEA as a Diff or Merge Command Line Tool

In this topic:

Overview

Besides using IntelliJ IDEA as an Integrated Development Environment, you can use it as a command line tool for comparing and merging files.

IntelliJ IDEA executable is platform-dependent: idea.exe or idea.bat for Windows and idea.sh for Linux.

For OS X, the executable is /Applications/idea.app/Contents/OS X/.... To add the launcher to your path, add its containing directory /Applications/idea.app/Contents/OS X.

Enabling invocation of IntelliJ IDEA operations from the command line

To enable invoking IntelliJ IDEA operations from the command line, do one of the following

  • Using the command line commands, for example, cd to change the directory, switch to the directory where the IntelliJ IDEA executable file is located (IntelliJ IDEA installation directory). The CMD commands, the name of the IntelliJ IDEA executable, and its default location depend on the operating system you use. See the lists of CMD commands for Windows, OS X, Linux.
  • Specify the location of the IntelliJ IDEA executable in the Path system environment variable. In this case, you will be able to invoke the IntelliJ IDEA executable and other IntelliJ IDEA command from any directory.

Comparing files using IntelliJ IDEA as a diff command line tool

To compare two files using IntelliJ IDEA as a diff command line tool

  1. Enable invoking IntelliJ IDEA operations from the command line.
  2. Type the following command at the command line prompt:
    <IntelliJ IDEA launcher> diff <path to file1> <path to file2>
    where file1 is your local copy, file2 is the repository version.

Merging files using IntelliJ IDEA as a command line tool

Most often you need to merge three versions of the same file: your local version, the version in the repository or in the upstream, and the base revision, which is the origin for the two diverged versions.

To merge files using IntelliJ IDEA as a command line tool

  1. Enable invoking IntelliJ IDEA operations from the command line.
  2. Type the following command at the command line prompt:
    <IntelliJ IDEA launcher> merge <path to file1> <path to file2> <path to file3> <path to output>
    where file1 is your local copy, file2 is the repository version, file3 is the base revision for file1 and file2, and output is the file to save the merge results in (optional).

Example

alias idiff='/Applications/idea.app/Contents/OS X/idea diff $

See Also

Last modified: 4 December 2014
comments powered by Disqus