Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

p4merge and Git 1.8.3

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.
like image 697
Mahmoud Samy Avatar asked Oct 21 '13 10:10

Mahmoud Samy


1 Answers

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.

like image 150
Guy Avraham Avatar answered Sep 19 '22 15:09

Guy Avraham