Tuesday, December 31, 2013

Use p4merge for git diff and merge on mac (update based on p4merge for mac 2018)

(update based on mac P4Merge 2018)

Assuming p4merge is already installed on mac in the default /Application folder.

1. create a sh script file called mymerge.sh with below content in /usr/local/bin folder
#!/bin/sh 
/Application/p4merge.app/Contents/Resources/launchp4merge $*


2. create a sh script file: /usr/local/bin/extMerge with the following content
#!/bin/sh mymerge.sh $*

3.create another script file: /usr/local/bin/extDiff with the following content
#!/bin/sh
[ $# -eq 7 ] && /usr/local/bin/extMerge "$2" "$5"
4. set the execute permission for the above files
$ sudo chmod +x /usr/local/bin/mymerge.sh
$ sudo chmod +x /usr/local/bin/extMerge $ sudo chmod +x /usr/local/bin/extDiff
5. edit .gitConfig file under the user home directory as below
[merge] tool = extMerge [mergetool "extMerge"] cmd = extMerge \"$BASE\" \"$LOCAL\" \"$REMOTE\" \"$MERGED\" trustExitCode = false prompt = false [diff] external = extDiff tool = extDiff [difftool "extDiff"] cmd = mymerge.sh \"$LOCAL\" \"$REMOTE\" trustExitCode = false prompt = false

6. run
git diff
or
git difftool
or
git mergetool
on an updated repository to see the result.

Link:
https://community.perforce.com/s/article/2848
http://git-scm.com/book/en/Customizing-Git-Git-Configuration

1 comment:

  1. It is soo informative. Are you also searching for cheap assignment writing help we are the best solution for you. We are best known for delivering the best services to students without having to break the bank

    ReplyDelete