I have inside my .gitconfig
[merge]
tool = intellij
[mergetool "intellij"]
cmd = /usr/local/bin/idea merge $(cd $(dirname "$LOCAL") && pwd)/$(basename "$LOCAL") $(cd $(dirname "$REMOTE") && pwd)/$(basename "$REMOTE") $(cd $(dirname "$BASE") && pwd)/$(basename "$BASE") $(cd $(dirname "$MERGED") && pwd)/$(basename "$MERGED")
trustExitCode = true
so I can run git mergetool
and get Intellij IDEA's mergetool.
The problem with this is since we are executing from /usr/local/bin/idea
requires admin privileges. However, if I run sudo git mergetool
IDEA would run this time, but as sudo, causing all the files changed to have changed permissions, in particular, changing the ownership of the file. Further it does not load user-specific config when running as sudo.
What would be the solution?