Use p4merge from Perforce as default git mergetool

p4merge-conflict-resolution-screenshot

A while ago this took more effort as described in this link (scroll to section ‘External Merge and Diff Tools’).

Not anymore. Now git natively supports p4merge. So you only need to modify your global git config (~/.gitconfig):

[merge]
	tool = p4merge
[mergetool "p4merge"]
	path = p4merge.exe
[diff]
	tool = p4merge
[difftool "p4merge"]
	path = p4merge.exe

You can provide the absolute path to the p4merge binary, but I have it on PATH because I installed it with scoop.

Install p4merge with scoop

To get scoop, from the PowerShell execute:

Set-ExecutionPolicy RemoteSigned -scope CurrentUser
iex (new-object net.webclient).downloadstring('https://get.scoop.sh')

p4merge is in the extras scoop bucket, add the bucket first to be able to install it easily:

scoop bucket add extras

then you can install p4merge

scoop update
scoop search p4merge
scoop install p4merge

To list all you installed scoop apps with PowerShell:

(scoop list) | sls '^  (\w+)' |% { $_.matches.groups[1].value }

Full .gitconfig

My full .gitconfig is below. It [include]s two paths .gitaliases and .gitmorealiases, they are both just text files in my home directory, i.e. they are siblings of my global .gitconfig file. They contain, you guessed it, git aliases. A large collection of aliases is available here. And here is a very useful blog post / tutorial introducing you to the usefulness of aliases.

Principal Bioinformatics Scientist

My main research interests are data visualization and signal processing for mass spectrometry.