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

AWS GenAI LIVE image

Real challenges. Real solutions. Real talk.

From technical discussions to philosophical debates, AWS and AWS Partners examine the impact and evolution of gen AI.

Learn more

Top comments (0)

Sentry image

See why 4M developers consider Sentry, “not bad.”

Fixing code doesn’t have to be the worst part of your day. Learn how Sentry can help.

Learn more

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay