tags:

views:

423

answers:

2

Consider the following problem. You remove code from a file in changeset 10. Later on you realise that code should not have been removed, and you want to merge it back into your latest version.

How do you do that with TFS with Visual Studio?

With (Win)CVS that's as simple as selecting the file and using the update command's merge options to merge the changes from an older revision back into your latest version. In TFS I can't figure out how to do this.

Using the "Get specific version" option seems to be overwritting my recent changes without allowing me to merge.

For now the only option I seem to have is to get the file old file manually from the changeset and merge the changes back using a diff tool on the latest version.

A: 

You could try and trigger a merge conflict, in order to get the merge tool to run.

On your machine get spesific version, add a space and save.

On some one elses machine, get latest version, add a space, save and checkin.

On your machine, try and checkin, this should give you a merge confict and start the merge tool.

Shiraz Bhaiji
+1  A: 
tfpt rollback file.cs /changeset:10

See tfpt rollback /? for more options.

You could do the same thing with a series of built-in commands -- tfpt only calls public APIs -- but unless you are really comfortable with the 3-way merge/conflict/resolution terminology that TFS uses, it's far less error prone if you let a tool handle it.

The downside is that it's quite slow. (for safety's sake, it syncs your entire workspace first, even if you're only touching 1 file) The rollback built into TFS 2010 executes on the server and is thus able to be much more intelligent.

Richard Berg
Does this perform a simple rollback, or does it allow changes from the previous version to be merged back into the most recent version?
It's too bad you need power tools for this kind of thing btw. I'd say it's basic functionality for a source control system...
This only undoes the changes made in #10. Changes made in subsequent changesets are preserved (to the best of your merge tool's ability, anyway).
Richard Berg