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.

  • Oran

    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
    Oran

  • Anonymous

    I get ‘Unable to determine the workspace…’, even though I have exactly one workspace.

  • Anonymous

    TFS is just awful at resolving this. The solution should be to have the option and simply remove the changeset altogether from the history.