error with p4merge merging tool in git
Asked Answered
M

10

12

I have setup my classpath for p4merge an set the file .gitconfig, but there i get this error when the p4merge tool suppose to opem those two files that are in conflict. anybody knows the solution?

added to classpath: "C:\Program Files\Perforce\p4merge.exe" added to .gitconfig file:

[merge]
    tool = p4merge
[mergetool "p4merge"]
    cmd = p4merge.exe \\\"$BASE\\\" \\\"$LOCAL\\\" \\\"$REMOTE\\\" \\\"$MERGED\\\"

ERROR MESSAGE:

Normal merge conflict for 'protected/views/layouts/main.php':
  {local}: modified file
  {remote}: modified file
Hit return to start merge resolution tool (p4merge):
C:\Program Files (x86)\Git/libexec/git-core/mergetools/p4merge: line 8: p4merge:
 command not found
protected/views/layouts/main.php seems unchanged.
Was the merge successful? [y/n] n
merge of protected/views/layouts/main.php failed
Manaus answered 24/5, 2012 at 17:5 Comment(0)
R
6

It works for me:

[merge]
    keepBackup = false;
    tool = p4merge
[mergetool "p4merge"]
    path = C:/Program Files/Perforce/p4merge.exe
    cmd = \"C:/Program Files/Perforce/p4merge.exe\" "$BASE" "$LOCAL" "$REMOTE" "$MERGED"
    keepTemporaries = false
    trustExitCode = false
    keepBackup = false
[difftool]
    prompt = false
[mergetool]
    prompt = false
Revelation answered 9/9, 2013 at 10:33 Comment(2)
keepTemporaries by default is false. In any case, it should be set as mergetool.keepTemporaries, not mergetool.<Tool>.keepTemporaries. KeepBackup is also set without specifying <Tool>.Pagurian
trustExitCode shouldn't be set to false (it should be default - true).Pagurian
A
5

Why is everything so hard I hate to write commands so what I did?

  1. Install p4Merge tool form here serach for P4Merge and install the exe then you need only

enter image description here

  1. Install it as Windows user

  2. Go into your user direcotry and search for .gitconfig edit it and add

[mergetool "p4merge"]
  path = C:\\Program Files\\Perforce\\p4merge.exe
  cmd = \"C:/Program Files/Perforce/p4merge.exe\" "$BASE" "$LOCAL" "$REMOTE" "$MERGED"
[merge]
  tool = p4merge

How to use it? When you pull something and have conflicts you can just write

git mergetool

And the tool will be open.

enter image description here

At the bottom is you final version you can edit there then just save and commit and the conflict will be resolved.

Annuity answered 8/11, 2016 at 21:23 Comment(2)
The option path isn't necessary.Pagurian
Thank you for sharing! This has been messing with me for almost two weeks and command-line-based solutions weren't helping. Never knew we could view the git configuration from the user directory.Ruffian
I
3

You may also need to restart your git console if you've just installed p4merge, for the updated environment variables to register.

Ingeingeberg answered 12/6, 2012 at 16:32 Comment(0)
R
2

After I installaed P4Merge, I followed the instructions on this page and it works perfectly for me.

https://gist.github.com/tony4d/3454372

Rubbery answered 31/1, 2014 at 16:21 Comment(1)
Too bad it's for OSX and the OP is clearly on Windows.Preconception
S
1

It looks like it can't find p4merge so try adding "C:\Program Files\Perforce\" to your PATH environment variable via System Properties.

Smithy answered 24/5, 2012 at 18:13 Comment(0)
E
1

If you don`t want to add p4merge in environmental variable Path (as Dan Lister mentioned) you could add parameter path in your git config:

[mergetool "p4merge"]
    path = C:/Program Files/Perforce/p4merge.exe

It works for me on git v1.7.11 (WinXP).

Eckhardt answered 5/2, 2013 at 14:4 Comment(1)
I don't like tabs order REMOTE, BASE, LOCAL. It's better to use cmd = 'C:/Program Files/Perforce/p4merge.exe' $BASE $LOCAL $REMOTE $MERGEDPagurian
V
0

Add the full P4merge path to your .gitconfig. Here's mine (note that the path separators are flipped around, i.e. c:/ instead of c:\):

[merge]
    tool = p4
[mergetool "p4"]
    cmd = c:/winprogs/p4merge/p4merge.exe \"$BASE\" \"$LOCAL\" \"$REMOTE\" \"$MERGED\"
Vesuvius answered 24/5, 2012 at 19:10 Comment(1)
If path to the exe contains spaces then it should be in quotes. cmd = 'C:/Program Files/Perforce/p4merge.exe' $BASE $LOCAL $REMOTE $MERGEDPagurian
F
0
These steps worked for me.

After downloading and installing P4Merge tool from perforce.com

After your profile name/email id.

Replace this content in your ~/.gitconfig file

 enter code here

[merge]
  keepBackup = false
    tool = p4merge
[mergetool "p4merge"]
    cmd = /Applications/p4merge.app/Contents/Resources/launchp4merge "\"$PWD/$BASE\"" "\"$PWD/$LOCAL\""  "\"$PWD/$REMOTE\"" "\"$PWD/$MERGED\""   
    keepTemporaries = false
    trustExitCode = false
    keepBackup = false
[diff]
    tool = p4merge
[difftool "p4merge"]
    cmd = /Applications/p4merge.app/Contents/Resources/launchp4merge "\"$REMOTE\"" "\"$LOCAL\""
Fabrianne answered 12/10, 2017 at 18:13 Comment(0)
W
0

Use this for the proper set up as merge tool.

  • $ git config --global merge.tool p4mergetool

  • $ git config --global mergetool.p4mergetool.cmd \ "/Applications/p4merge.app/Contents/Resources/launchp4merge \$PWD/\$BASE \$PWD/\$REMOTE \$PWD/\$LOCAL \$PWD/\$MERGED"

  • $ git config --global mergetool.p4mergetool.trustExitCode false

  • $ git config --global mergetool.keepBackup false

Reference: https://gist.github.com/tony4d/3454372

Wellesz answered 22/7, 2019 at 21:33 Comment(0)
K
0

1) edit your git config file

git config --edit --global

2) add following (change accordingly)

[merge]
    keepBackup = false;
    tool = p4merge
[mergetool "p4merge"]
    path = C:/Program Files/Perforce/p4merge.exe
    cmd = \"C:/Program Files/Perforce/p4merge.exe\" "$BASE" "$LOCAL" "$REMOTE" "$MERGED"
    keepTemporaries = false
    trustExitCode = false
    keepBackup = false
[diff]
    tool = p4mergetool
[difftool "p4merge"]
    cmd = /Applications/p4merge.app/Contents/Resources/launchp4merge $LOCAL $REMOTEhere

3) initialize the config file

git init

All set, you are ready to go.

Karlenekarlens answered 28/5, 2020 at 6:53 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.