WHAT'S NEW?
Loading...

Git: Perforce is our new diff / merge tool

If you are one of those noob Git users like me probably you faced this problem already. My Git does not provide a merge tool by default. I used to work with TortoiseSVN merge tool but as long as I work more time with Git, I have the need to try more commands and learn more about this amazing tool.

Let's start with the premise you have Git already installed in your computer. First of all, we'll execute a command to know which info can we get about the merge tools we have in our computer. Run this in your Git console: git mergetool --tool-help



As you can see in the previous screenshot, I already have some tools to configure Git and start merging code by using vim or tortoise. Tortoise is already there because I use it as a GUI but now we'll configure perforce to give it a go. First of all you need to download the Perforce tool from its web using the link close to P4Merge: Visual Merge Tool. After install the app, go back to the git console and run the following commands to setup Perforce as default merge tool in Git:


git config --global merge.tool p4merge


git config --global mergetool.p4merge.cmd 'p4merge.exe \"$BASE\" \"$LOCAL\" \"$REMOTE\" \"$MERGED\"'

As you can see in the following image now we are able to see p4merge is configured already:



Unfortunately, if we want to run the merge tool in our solution by using git mergetool we won't see it yet. You need to make a small change within your .gitconfig file. Open the file (C:\Program Files (x86)\Git\etc) and add the following lines at the end of it:

[merge]
   tool = p4merge
[mergetool]
   keepBackup = false
   prompt = false

After this step I faced an issue from p4merge telling me it was not able to open my cs classes and compare them. A workaround is to execute the two commands I posted in lines above. That solved the problem I was able to work with p4!!!


Looking forward to your comments and feedback!


0 comments:

Post a Comment