p4merge and Git 1.8.3
Asked Answered
S

3

10

How can I config git to use p4merge as my mergetool?

Next is my current situation:

$ git --version
git version 1.8.3.msysgit.0

$ git mergetool

This message is displayed because 'merge.tool' is not configured.
See 'git mergetool --tool-help' or 'git help config' for more details.
'git mergetool' will now attempt to use one of the following tools:
tortoisemerge emerge vimdiff
No known merge tool is available.
Sedberry answered 21/10, 2013 at 10:18 Comment(2)
This answer shows you how to do it.Tav
I have tried it before. It caused my problemSedberry
U
1

I just posted an article that explains how to integrate Git with P4Merge along with a launcher script that irons out few discrepencies: http://pempek.net/articles/2014/04/18/git-p4merge/

Urania answered 19/4, 2014 at 8:25 Comment(1)
After having tried several previous demo examples this is the example that worked best for me.Belenbelesprit
N
25

To install p4merge and set it as git's difftool & mergetool on a Linux machine (Ubuntu 16.04) I did the following:

  1. Go to the Downloads page of Perforce website, and in the search bar write: p4merge.

  2. Chose the p4merge for Linux platform and download it (note that you can skip the registration).

  3. Once downloaded extract it and copy the contents of the folder to a new folder /opt/p4merge:

    a) gunzip p4v.tgz

    b) tar xvf p4v.tar

    c) sudo mkdir /opt/p4merge

    d) I have downloaded it to /home/guya/Downloads and the "extracted" p4merge folder was (08/19) p4v-2019.1.1830398, so in my case the command was:

    sudo mv /home/guya/Downloads/p4v-2019.1.1830398/* /opt/p4merge

  4. Create a symbolic link to the p4merge executable with the command:sudo ln -s /opt/p4merge/bin/p4merge /usr/local/bin/p4merge

  5. Add the following commands to git's "global config settings" so p4merge will be used as both git's difftool & mergetool:

    git config --global merge.tool p4merge git config --global mergetool.p4merge.path /usr/local/bin/p4merge git config --global mergetool.prompt false

    git config --global diff.tool p4merge git config --global difftool.p4merge.path /usr/local/bin/p4merge git config --global difftool.prompt false

  6. In order to see diff's (between Working directory to the staging area, for instance) you can now use the command:git difftool that will open the p4merge GUI to be used.

NOTE: git diff will still work and will display the diffs in the terminal.

Nevels answered 24/8, 2019 at 9:12 Comment(1)
For some reason when I paste those git config -- commands, when I exit and try "git difftool" I get "fatal: bad config line 1 in file .gitconfig"Suberin
S
3

The article Installing and Using P4Merge in Git for Windows worked for me.

Edit your global .gitconfig and add the following sections (you don't have to worry about where p4merge.exe is located, it was added to your path during the installation):

[diff]
    tool = p4merge
[difftool "p4merge"]
    cmd = "p4merge.exe $LOCAL $REMOTE"
[merge]
    tool = p4merge
[mergetool "p4merge"]
    cmd = "p4merge.exe $BASE $LOCAl $REMOTE $MERGED"
    trustExitCode = true
    keepTemporaries = false
    keepBackup = false
    prompt = false

There is one caveat, in order to run "git difftool' or "git mergetool" you have to first run "git diff" or "git merge" and have a difference or conflict. The editor will then launch with the correct files ready for editing.

Sedberry answered 21/10, 2013 at 10:47 Comment(0)
U
1

I just posted an article that explains how to integrate Git with P4Merge along with a launcher script that irons out few discrepencies: http://pempek.net/articles/2014/04/18/git-p4merge/

Urania answered 19/4, 2014 at 8:25 Comment(1)
After having tried several previous demo examples this is the example that worked best for me.Belenbelesprit

© 2022 - 2024 — McMap. All rights reserved.