Skip to content

Instantly share code, notes, and snippets.

@ctreffs
Last active July 31, 2026 09:46
Show Gist options
  • Select an option

  • Save ctreffs/966d4d4fc80a29f2ad4750d26f3848d6 to your computer and use it in GitHub Desktop.

Select an option

Save ctreffs/966d4d4fc80a29f2ad4750d26f3848d6 to your computer and use it in GitHub Desktop.
Setting up IntelliJ IDEA as Diff and Merge Tool in Fork

Setting up IntelliJ IDEA as Diff and Merge Tool in Fork

To configure Fork to use IntelliJ IDEA for diffing and merging, follow the steps below.


1. Prerequisites

Ensure you have the command-line launcher idea installed.

  • Path: /usr/local/bin/idea
  • You can verify this by running which -a idea in your terminal.

2. Configure the External Diff Tool

  1. Open Fork and go to Preferences / Settings (Cmd + ,).
  2. Select the Integration tab.
  3. Under External Diff Tool, select Custom... from the dropdown and click Edit... (or click Edit... if already selected).
  4. Configure the fields as follows:
    • File Path: /usr/local/bin/idea
    • Arguments: diff $LOCAL $REMOTE
  5. Click Edit to save.

3. Configure the External Merge Tool

When merging files that were added in both branches independently (where no common base file exists), Fork passes an empty $BASE variable. To prevent IntelliJ IDEA from failing with a "Can't process file" error, we can delegate the merge to a lightweight custom wrapper script.

Setup Instructions

1. Create the wrapper script

Create a file named idea-merge-fork (for example, in /usr/local/bin/idea-merge-fork or any other directory on your $PATH):

#!/bin/sh
if [ -f "$3" ]; then
    /usr/local/bin/idea merge "$1" "$2" "$3" "$4"
else
    /usr/local/bin/idea merge "$1" "$2" "$4"
fi

Make the script executable:

chmod +x /path/to/idea-merge-fork

2. Configure Fork

  1. In Fork's Integration tab, under Merge Tool, select Custom... and click Edit....
  2. Configure the fields as follows:
    • File Path: /path/to/idea-merge-fork (replace with the absolute path to your script)
    • Arguments: $LOCAL $REMOTE $BASE $MERGED
  3. Click Edit to save.

4. Verification

Now, whenever you perform a merge conflict resolution or want to view external diffs within Fork, it will launch IntelliJ IDEA with the correct files and UI windows automatically!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment