Took some time to figure out arguments.
Diff command text box should contain path to intellij, like: /Applications/IntelliJ\ IDEA\ 12.app/Contents/MacOS/idea
IntelliJ Diff Tool in SourceTree
-
07-03-2022 - |
Question
Is it possible to use IntelliJ Diff tool in SourceTree? I know it is accessible from terminal.
Thanks
Solution 2
OTHER TIPS
For OSX android studio i've accomplished with this steps:
Open IntelliJ/Android Studio -> Tools -> Create Command Line Launcher
After that, open SourceTree Preferences: and put "/usr/local/bin/studio" in Diff/Merge Command. Like this:
Diff Arguments:
diff $LOCAL $PWD/$REMOTE
Merge Arguments:
merge $PWD/$LOCAL $PWD/$REMOTE $PWD/$BASE $PWD/$MERGED
And if everything it's ok it should work.
Windows
Diff Command: C:\Program Files (x86)\JetBrains\IntelliJ IDEA 12.1.2\bin\idea.exe
Arguments: diff $LOCAL $PWD/$REMOTE
Merge Command: C:\Program Files (x86)\JetBrains\IntelliJ IDEA 12.1.2\bin\idea.exe
Arguments: (This isn't working right for me. I'm having pathing problems.) merge $LOCAL $PWD/$REMOTE $PWD/$BASE $MERGED
As of 12.1, these are the arguments for using IntelliJ's diff and merge tools from outside the program:
Diff tool
<path to IntelliJ IDEA launcher> diff <path to file1> <path to file2>
Merge tool
<path to IntelliJ IDEA launcher> merge <path to file1> <path to file2> <path to file3> <path to output>
OFFICIAL DOCUMENTATION: running-intellij-idea-as-a-diff-or-merge-command-line-tool
FWIW, I ended up using IntelliJ for my source control. I like it more than Sourcetree. It's quite robust.
For today (January 2019) it works at windows like this:
External Diff/Merge:
Diff tool:
Diff Command: C:\Program Files\JetBrains\WebStorm 2018.3.1\bin\webstorm64.exe
Agruments: diff $LOCAL $REMOTE
Merge Tool:
Diff Command: C:\Program Files\JetBrains\WebStorm 2018.3.1\bin\webstorm64.exe
Agruments: merge $LOCAL $REMOTE $BASE $MERGED
If somebody is interested in Android Studio settings in Mac:
<path to IntelliJ IDEA launcher>:
/Applications/Android\ Studio.app/Contents/MacOS/studio
Diff tool
<path to IntelliJ IDEA launcher> diff <path to file1> <path to file2>
Merge tool
<path to IntelliJ IDEA launcher> merge <path to file1> <path to file2> <path to file3> <path to output>
The only problem which I notice is that Android Studio cannot show more than 1 diff at once. When I try, it complains that the file cannot be showed
On Mac with intellij 2016
diff $LOCAL $PWD/$REMOTE
merge $PWD/$LOCAL $PWD/$REMOTE $PWD/$BASE $PWD/$MERGED
For the merge-tool on windows, these arguments work for me:
merge $PWD/$LOCAL $PWD/$REMOTE $PWD/$MERGED
Using PHPStorm 2013 on Windows and Sourcetree >2.4 I had to escape the arguments and add a full path to the merge options.
Diff / Merge command:
C:\Program Files\JetBrains\PhpStorm 2017.3.6\bin\phpstorm64.exe
diff arguments:
diff \"$LOCAL\" \"$REMOTE\"
merge arguments:
merge \"$PWD/$LOCAL\" \"$PWD/$REMOTE\" \"$PWD/$MERGED\"
merge \"$PWD/$LOCAL\" \"$PWD/$REMOTE\" \"$PWD/$BASE\" \"$PWD/$MERGED\"
On macOS with IntelliJ IDEA CE.
Diff Command: open
Arguments: -W -b com.jetbrains.intellij.ce --args diff "$LOCAL" "$PWD/$REMOTE"
Where:
open
: System command to open files and directories.-W
: Causesopen
to wait until the applications it opens (or that were already open) have exited.-b com.jetbrains.intellij.ce
: Bundle identifier for the application to use when opening the file.--args
: All remaining arguments are passed to the opened application in theargv
parameter tomain()
.
As @Shad mentioned, IntelliJ may not perform a diff/merge in Windows because the temporary files have not yet been created.
A workaround is to create a file delayed-intellij.bat
as follows:
ping 127.0.0.1 -n 2 > nul
"C:\Program Files\JetBrains\IntelliJ IDEA 2017.2.1\bin\idea64.exe" %*
Then use this file in Sourcetree: C:\temp\idea64-delayed.bat
, and it will launch the merge tool with a short delay.
Got IntelliJ to work as SourceTree's diff and merge tool with
- macOS 10.14.6
- IntelliJ IDEA 2019.2.1 (Community Edition)
- SourceTree 3.2.1 (225)
using
Diff Command: open
Arguments: -W -b com.jetbrains.intellij.ce --args diff "$LOCAL" "$PWD/$REMOTE"
Merge Tool: open
Arguments: -W -b com.jetbrains.intellij.ce --args merge "$PWD/$LOCAL" "$PWD/$REMOTE" "$PWD/$BASE" "$PWD/$MERGED"
at SourceTree > Preferences > Diff
.
See https://i.stack.imgur.com/YEQEV.png for a screenshot.
Hope this helps somebody :-)