How to: Use tf merge /discard?
In a previous post, I mentioned some details about merge history bookkeeping. In a nutshell, when you merge, you are giving credit to the target branch for the range of versions you’re merging over. That’s why you see the merge change type pended on the target items, because it means that this will be recorded in the bookkeeping system, or merge history, when you commit this change so that you don’t re-merge the same versions/changes next time. However, sometimes you just need to record that merge in merge history without merging over the actual changes. This will give the target branch credit for these versions and discard porting the changes over. You guessed it right, that’s when you use tf merge with the /discard option then check in to commit the merge operation.
Note: If you use TFS 2008 SP1 and run tf merge /baseless /discard, there’s a known issue that was fixed here.
Comments
Anonymous
October 18, 2012
Thanks for the post, it’s really helpful but I have one question. Because it’s still required to check in the change on the “target” branch (even though there are in fact no changes) TFS creates a new changeset on the “target” branch which then appears as a merge candidate for a reverse merge. Seems to me like it’s only moving the problem from one place to another. Am I missing something? Thanks OranAnonymous
October 22, 2012
Oran, thanks for commenting. I'm not working on TFS anymore, so I recommend that you post the question on the TFS forum: social.msdn.microsoft.com/.../threads There could be new changes in the product that I'm not aware of.