DEV Community

Abhiyan Shrestha
Abhiyan Shrestha

Posted on

P4 merge in ubuntu

I have been using phpstorm builtin merge conflict resolving editor, lately, I switched to vscode, but the 3 way merge editor of vscode sucks. So, I discovered this tool called P4 merge which helps to resolve conflict in much easier way.To install in ubuntu, here are the following steps

Install P4 on ubuntu

cd ~/Downloads
wget https://cdist2.perforce.com/perforce/r18.2/bin.linux26x86_64/p4v.tgz
tar zxvf p4v.tgz
sudo mkdir /opt/p4v
cd p4v-2018.2.1666551 // this may be changed based on the version being downloaded
sudo mv * /opt/p4v
sudo ln -s /opt/p4v/bin/p4merge /usr/local/bin/p4merge

nano ~/.gitconfig

[merge]
    tool = p4merge

[mergetool]
    prompt = false
    keepBackup = false

[mergetool "p4merge"]
    cmd = p4merge "$BASE" "$LOCAL" "$REMOTE" "$MERGED"
    keepTemporaries = false
    trustExitCode = false
    keepBackup = false  
Enter fullscreen mode Exit fullscreen mode

Extension required in vscode

After merging relevant branches in vscode, if any file gets conflict simply, open that file and press ctrl + shift + p and enter Terminal: Git mergetool. For that this extension Terminal mergetool must be installed.

The p4 merge editor will look like:

p4 merge editor

References:
P4merge manual

Top comments (0)