by Stian

TFS: Discard changes in merge

imagesWhen merging between two branches in TFS, you get a list containing specific changesets that have been checked into the source branch but not merged into the target branch. Sometimes these are changesets that you never want to merge into your target branch and they are just messing up for you (because at some point you are going to hurry through this wizard and accidentally  select “Merge all changesets”).

Well, no need to kill yourself yet: you can always discard these changesets and forget all about them. There is no way to do this in Visual Studio GUI, so you will need to fire up the Visual Studio Command Prompt.

Make sure you are in your workspace directory and write a command like:

tf merge $/project/branch $/project/trunk /discard /recursive /version:C666~C688

Version is FROM changeset ~ TO changeset. If you are only discarding one changeset, you would repeat the changeset like this /version:C666~C666.

It should also be mentioned that you are still required to check in the changes, even though there is essentially no change in the file content.