The P4merge software is used to resolve the Git conflicts like comparing the files, branching and merging the files.
P4merge is a visual tool for diffing and merging files and it allows us to view the difference between files across time and across code lines.
P4merge also enables us to merge different files into one.
Now click on the yes to install the software, and then it begins installing, On the first page of the installer, it will ask you to select the needed software to be download, then you can select the application which you required.
Let's Configure P4merge accessible from any command prompt, First thing is to test whether the P4merge is accessible or not, and this process will work with Git bash, power shell and also with the Windows command prompt.
Now, let's find out the p4merge.exe file, go to the My computer, under that go to Local disk, in that select program files, there you can find the perforce folder and then, click on perforce.
You can see the p4merge application file, select the p4merge and all we need is a path to the p4merge, Then go to the address bar and click on it, you will get the address and then copy the path.
Under the system variables, select the path and click on the Edit, then it will take you to the address path bar, hence to separate the address values, first enter the semicolon and paste the address that you copied before and then click on Ok on all the tabs and close it.
Here I am going to configure P4merge to work with Git. First, let's find where P4merge has installed.
By default, the programs will installed in the Local disk, under that select the program files and in that, you can see a folder by the name called perforce, which is the name of the company that makes p4merge.
Going into that folder you can see a p4merge application file, Just double click on that, it will launch the p4merge. now, we know the location, just close and go back and then open the Git Bash.
I am going to position the Git Bash window so that, I can able to see the address path of the application file.
So by using the Git config command, am going to config Git to use p4merge as the merge resolution tool.
I will pass the command as
git config --global merge.tool p4merge, because these settings are needed to be at the user level and then press enter.
git config --global mergetool.p4merge.path "c:/programfiles/perforce/p4merge.exe"
So the next command tells Git not to prompt and not to launch p4merge, so every time we need to resolve a conflict, We will pass another command to resolve a conflict as
git config --global mergetool.prompt false
Now setup the difftool configuration, same as in the last example, we are going to use a similar syntax, except use difftool,
git config diff.tool p4merge and press enter and
git config --global difftool.p4merge.path "c:/programfiles/perforce/p4merge.exe" and press enter.
The last command to configure out difftool is
git config --global difftool.prompt false
git config --global --listpress enter.
git config --global -ewill invoke our default editor with a .gitconfig file.
Most of the configuration that is set up in the .gitconfig file is related to the difftool and merge tool. Now let's close the default window by using Ctrl+W and Alt+F4.
In the next article called Git Comparisons, you are going to understand clearly about how p4merge is useful in comparing, merging and branching.