IntellJ IDEA contains a very good merge UI, ideal to resolve conflict during merge or rebase.
The functionality is accessible also from command line, without having a project with the conflicting sources.
Integration into the git commandline flow is quite easy, as git already has the concept of diff- and mergetools.
|
ℹ️
|
This description focuses on Mac OS, but the same pattern should be applicable to other operating systems as well. |
To make the realpath command available, coreutils is required and can be installed with brew install coreutils
To configure IntelliJ IDEA as diff- and mergetool, adjust the git-config - usually located at ~/.config/git/config - as follows.
[alias]
gdiff=difftool --dir-diff -y -t intellij
resolve=mergetool -t intellij --prompt
[diff]
tool = intellij
[difftool "intellij"]
cmd = /Applications/IntelliJ*.app/Contents/MacOS/idea diff $(realpath "$LOCAL") $(realpath "$REMOTE") 2>/dev/null
[merge]
tool = intellij
[mergetool]
keepBackup = false
[mergetool "intellij"]
cmd = /Applications/IntelliJ*.app/Contents/MacOS/idea merge $(realpath "$LOCAL") $(realpath "$REMOTE") $(realpath "$BASE") $(realpath "$MERGED") 2>/dev/null
trustExitCode = trueFor the IntelliJ-based diff, use git gdiff as base-command.
Specific files, additional parameters etc. can be added, just as with the regular diff-command.
Conflict-resolution is performed with the alias git resolve.
|
💡
|
Due to the "prompt"-parameter in the |