How to get p4merge to come up when I do git mergetool and not filemerge
I'm on macOS Mojave, Git version 2.19.0
When doing git mergetool
, instead of p4merge, filemerge
comes up.
Searched my entire drive and the only instance of p4merge I see is in
/Applications/Sourcetree.app/Contents/Resources/git_local/libexec/git-core/mergetools/p4merge
Am I missing something, I think perhaps I need to install p4merge or something..
Here is what I have done already:
ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)" < /dev/null 2> /dev/null ; brew install caskroom/cask/brew-cask 2> /dev/null
brew cask install p4merge
When I do run the above command I get an error:
(master) ✚ >M< > brew cask install p4merge
Ignoring commonmarker-0.17.11 because its extensions are not built. Try: gem pristine commonmarker --version 0.17.11
Ignoring commonmarker-0.17.11 because its extensions are not built. Try: gem pristine commonmarker --version 0.17.11
Ignoring commonmarker-0.17.11 because its extensions are not built. Try: gem pristine commonmarker --version 0.17.11
Updating Homebrew...
Ignoring commonmarker-0.17.11 because its extensions are not built. Try: gem pristine commonmarker --version 0.17.11
==> Auto-updated Homebrew!
Updated 2 taps (homebrew/core and homebrew/cask).
==> Updated Formulae
conan
Error: Cask 'p4merge' is unavailable: No Cask with this name exists.
Solution 1:
It would be best to install p4merge directly from their vendor as their brew cask is not maintained by the authors. First download p4merge and drag & drop to your applications from their download page: https://www.perforce.com/downloads/visual-merge-tool
After p4merge.app
is under /Applications
you can configure git to use p4merge as default merge and diff tool.
There is active discussion in this gist document, better check the latest developments from there https://gist.github.com/tony4d/3454372
You can use the following configuration for Mojave.
[merge]
tool = p4mergetool
stat = true
[mergetool "p4mergetool"]
cmd = /Applications/p4merge.app/Contents/MacOS/p4merge "$BASE" "$LOCAL" "$REMOTE" "$MERGED"
keepBackup = false
keepTemporaries = false
trustExitCode = false
prompt = false
[diff]
tool = p4mergetool
renames = copies
mnemonicprefix = true
[difftool "p4mergetool"]
cmd = /Applications/p4merge.app/Contents/MacOS/p4merge "$LOCAL" "$REMOTE"
keepBackup = false
keepTemporaries = false
trustExitCode = false
prompt = false
Solution 2:
FWIW, there is no longer a brew cask for p4merge. It fails when I try that. I had to use
brew cask install p4v
Solution 3:
Halil Kaskavalci's answer had issues for me in that it continued to prompt me for every file to diff/merge and p4merge was allowed to lock the terminal, even after closing the application.
Here's what works for me:
[diff]
tool = p4mergetool
[difftool]
prompt = false
[difftool "p4mergetool"]
cmd = /Applications/p4merge.app/Contents/Resources/launchp4merge "$LOCAL" "$REMOTE"
keepBackup = false
keepTemporaries = false
trustExitCode = false
[merge]
tool = p4mergetool
[mergetool "p4mergetool"]
cmd = /Applications/p4merge.app/Contents/Resources/launchp4merge "$BASE" "$LOCAL" "$REMOTE" "$MERGED"
keepBackup = false
keepTemporaries = false
trustExitCode = false
prompt = false