66

I'd like to disable the automatic merge feature when checking in a file to TFS that another developer has worked on so that I always need to merge manually. Is there any way to do this?

jessehouwing
  • 87,636
  • 19
  • 214
  • 286
Bryan Anderson
  • 15,383
  • 7
  • 66
  • 81

3 Answers3

122

Try do the following (working in all Visual Studio versions from 2012-onwards):

Tools -> Options -> Source Control -> Visual Studio Team Foundation Server -> Uncheck "Attempt to automatically resolve conflicts when they are generated":

enter image description here

AStopher
  • 3,652
  • 10
  • 46
  • 67
Andrey
  • 1,229
  • 1
  • 8
  • 3
  • I think the user here wants to disable the ability to auto-merge entirely. I'm guessing that based on the fact that the option you reference didn't exist when this question was written... – Edward Thomson Feb 14 '13 at 17:44
  • Just in case if you need a link ..see this post http://www.donovanbrown.com/post/2013/01/31/I-dont-trust-2012-Auto-merge-but-it-does-it-automatically- – Amitd Jun 08 '15 at 11:27
  • 1
    Works even with VS2015! great help! – Tejasvi Hegde Sep 25 '15 at 15:35
  • 1
    This only works for conflicts, but VS doesn't always consider differences between branches to be conflicts. For instance, if you want the path to project references differ between branches. – xr280xr Feb 08 '16 at 15:45
3

The short answer as of Visual Studio 2008 seems to be no.

Bryan Anderson
  • 15,383
  • 7
  • 66
  • 81
0

Whenever two people have changed the same file, you have to "merge" the code. This can take three forms:

  • Keep your version (discarding their changes)
  • Keep their version (discarding your changes)
  • Merge both changes to blend them both together

You can't "turn this off", because there is no other safe way to resolve the clash.

The closest you can get to turning merging off is to disallow multiple checkouts (lock the file so that only one developer can work on it at a time). This prevents two concurrent edits occurring, and thus avoids the problem of merging entirely. (At the extra cost of developers often being blocked and unable to work on a file while another developer has the lock). This is an awful and usually inefficient way to work - I wouldn't recommend it.

You can minimise the need for merges:

  • Check in frequently. Many small changes reduces your exposure to merge conflicts, while a few large changes increase your exposure.
  • Split large and often-changed files up into many smaller files to minimise the chance that 2 developers need to chnage the same file at the same time
  • Before you start working on a file, check if anyone else is editing it, and try to reorganise your "schedule" so that you don't have to start editing that file while the other programmer is working on it (a self-imposed "soft lock", to just reduce the chance of merges being necessary)

You can also upgrade the merge tools. Visual Studio's merge is horrible, difficult to use, and often introduces problems into the code. It has bitten me so many times I cannot ever trust it, so have to do painful manual merges every time. I now use Araxis Merge which always does an automatic merge perfectly, giving me confidence that I can just leave it to do the merge for me. (I've never used another merge program that gives me that confidence, and I've tried pretty much every other option over the years). When a manual merge is required, it offers a very clear merge view to "read", and very quick and intuitive UI for choosing how to merge each bit of code, making it very efficient. I once struggled for 3 days with a complex merge in VS (corrupting the code several times until I gave up) then I bought Araxis Merge and re-did the entire merge perfectly in 15 minutes. A good tool really takes the pain out of merging.

(I am not affiliated with Araxis in any way, I just can't stand most of the terrible merge tools out there)

Jason Williams
  • 53,816
  • 11
  • 99
  • 129
  • 10
    I don't want to take away the merge capability. I just want to turn off the automatic merge "feature" because it tends to do so terribly. Basically I want it so I will always do a manual merge. – Bryan Anderson Nov 02 '09 at 21:28
  • I already have it set up to do manual merges in Winmerge which makes manual merges nearly painless. – Bryan Anderson Nov 02 '09 at 21:29
  • 1
    Ah. In that case, apologies for not being very helpful. I'm afraid I share your complaint (the number of dialogs you have to work through to round-trip the merge between VSTS and the merge tool is so frustrating, tedious and time-wasting! As soon as I get some free time, I think I'll just write a replacement front-end for TFS, 'cos the MS one (to use the technical term) truly sucks) – Jason Williams Nov 02 '09 at 21:46
  • No worries, I wasn't very clear in my question. I've edited it to hopefully be more clear. – Bryan Anderson Nov 02 '09 at 21:52
  • 1
    +1 for a great answer anyway. I'm sure someone will come to this question that really just needs a good explanation of merging and your answer will be a huge help. Also for future reference, here's how you set up VS to use a different diff/merge tool than the one built into VS: http://blogs.msdn.com/jmanning/articles/535573.aspx – Bryan Anderson Nov 05 '09 at 15:50