Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to integrate visual conflict resolution (P4Merge) into SourceTree

For quite some time now, I have been bedeviled by SourceTree's lack of usable conflict resolution.

There is supposed to be a procedure for integrating p4Merge or some other diff/merge tool into SourceTree. For the moment, p4Merge is my tool of choice; now I just need to figure out how to

  1. Get SourceTree to accept p4Merge as its merge/diff tool, and
  2. Be able to actually call p4Merge from SourceTree to resolve conflicts.

So far the only thing I've been successful at doing is getting P4Merge to display a diff from within SourceTree. So the Actions/External Diff menu item works, but the Actions/Resolve Conflicts/Launch External Merge Tool menu item does not (it is grayed out).

enter image description here

I have selected P4Merge for both the Diff tool and the Merge tool in the Tools/Options/Diff tab in SourceTree. I can't put anything in the two command line boxes (even if I knew what to put there), because they are also grayed out.

picture of Options/Diff dialog

How do I make this work?

SourceTree is at version 1.9.5.0, which should be the latest as of this writing. P4Merge doesn't appear to have a Help/About dialog, but it was installed recently (within the last 3 months).

like image 937
Robert Harvey Avatar asked Aug 02 '16 17:08

Robert Harvey


2 Answers

I have SourceTree version 1.5.2.0, and I configured external merge tool as seen on the screenshot. P4Merge is installed into C:\Program Files\Perforce and is not on the Path. I did not set any specific values into .gitconfig regarding diff/merge tools (I realize that this is kind of 'works on my machine answer', but it was indeed that simple).

here is how I configured external merge tool

As for the workflow, different teams may have different approaches. What we do in our team for each feature work (usually done by only one developer) is the following (screenshots for how to perform each operation in SourceTree are at the end of the post):

  1. Rebase develop branch
  2. Create new feature branch
  3. Work on a feature, make commits (usually, multiple)
  4. If there were many changes to develop since the time branching was done, we can merge develop to our feature branch to resolve any potential conflicts and make sure feature still works
  5. Merge to develop branch followed by Push - our CI is configured to trigger deployment to Test environment when new changes are pushed to develop branch
  6. If all is good, we merge develop branch to master branch, which would trigger deployment to Production environment

To rebase develop: enter image description here

To create new branch out of develop: enter image description here

To merge develop into feature branch:

enter image description here

Here is how SourceTree shows that there are conflicts after merge: enter image description here

Update: In order to verify whether SourceTree is configured correctly, I suggest you do the following:

  1. Download and unzip locally a small repository with two branches from https://1drv.ms/u/s!Ahrx2cBEbNLOy1xsUNuZJrUe80Ox
  2. Add this repository to SourceTree by executing: File - Clone/New... - Add Working Copy - [select folder 'git-config']
  3. Right-click on branch with name 'origin/version-2' and select 'merge'
  4. You should see the warning about merge conflicts, and then after right-click on file.txt, the following should appear:

enter image description here

like image 80
oldbam Avatar answered Sep 22 '22 19:09

oldbam


I think you don`t have problem with P4Merge. You problem is

Actions/Resolve Conflicts/Launch External Merge Tool menu item does not (it is grayed out)

I think sourceTree has this behavior because you don`t have conflicts in the current branch.

You may check this easy: Run command git mergetool master . -d and see output. I suppose output will be No files need merging.

If you have unresolved conflicts in current branch sourceTree Actions/Resolve Conflicts enabled for me:enter image description here

Please edit a question if you real porblem with P4Merge and with other mergetool sourceTree works fine.

like image 21
Dmitrii Zyrianov Avatar answered Sep 22 '22 19:09

Dmitrii Zyrianov