4

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.
6
  • What is p4merge? It is not a standard Apple or git tool
    – mmmmmm
    Commented Oct 19, 2018 at 18:04
  • It's a tool to view the differences between git commits. When you want to view the differences in graphical format, that is what you use when you issue the command git mergetool. I'm doing it on macOSX.
    – Stryker
    Commented Oct 19, 2018 at 19:09
  • So the qustion is really - How do I get p4merge? and nothing to do with git
    – mmmmmm
    Commented Oct 19, 2018 at 20:21
  • @mark p4merge is directly related to git commit differences. You can also use difftool but p4merge gives u a visual output put. I’m not sure if u can even use p4merge in its own
    – Stryker
    Commented Oct 19, 2018 at 21:36
  • p4merge is not a part of git - it is part of Perforce version control which you pay for. You can use it with git.
    – mmmmmm
    Commented Oct 20, 2018 at 11:12

3 Answers 3

8

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
2
  • This does not answer the issue as the OP has not managed to install p4merge and even if they had done so it would not be under /Applications as they art using Homebrew
    – mmmmmm
    Commented Dec 18, 2018 at 14:10
  • I totally misunderstood it. This answer was one of the search results for making p4merge work for Mojave and it's not a straightforward task. I updated the answer to include how to install p4merge properly though without using brew.
    – Halil
    Commented Dec 19, 2018 at 10:28
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
1
  • It would be nice if Homebrew made provisions for renamed projects. It would be nice if the brew command itself responded with something like "p4merge has been renamed to p4v. Would you like to install p4v instead?".
    – iconoclast
    Commented May 27, 2020 at 20:37
1

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

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .