views:

12958

answers:

10

I'd like to rollback a change I made recently in TFS. In Subversion, this was pretty straightforward. However, it seems to be an incredible headache in TFS:

Option 1: Get Prior Version

  1. Manually get prior version of each file
  2. Check out for edit
  3. Fail - the checkout (in VS2008) forces me to get the latest version

Option 2: Get TFS Power Tools

  1. Download Team Foundation Power Tools
  2. Issue rollback command from cmd line
  3. Fail - it won't work if there are any other pending changes

Option 3: Manually Undo Changes

  1. manually undo my changes, then commit a new changeset

Question

How do I rollback to a previous changeset in TFS?

+1  A: 

If you did 1 check-in and you just want to undo it, that has a changeset # associated with it. Do a history on the folder in question to see the bad changeset. Open it up to see the details (all files changed, etc).

I believe that you can restore or undo a changeset from that screen, but my Visual Studio just crashed when I tried to do this. /sigh -- I definitely share your pain.

Where do I downmod TFS on this site?

Ben Scheirman
Nope, rollback from the History UI was only added in TFS 2010.
Richard Berg
+1  A: 

I think that the Team Foundation Power Tools is the way to go. If there are pending changes you can move them to a shelveset then undo or check in all pending changes before running the rollback command. See http://www.codeplex.com/VSTSGuidance/Wiki/View.aspx?title=How%20to%20undo%20a%20check-in&referringTitle=Source%20Control%20Practices%20at%20a%20Glance for more information.

Phillip Wells
+4  A: 

Ahh, just found this CodePlex Article on using TFPT.exe (power tool) to rollback a changeset.

Hope this helps you out.

Ben Scheirman
+11  A: 

Your solution #1 will work: 1. manually get prior version of each file

  1. check out for edit

  2. Checkin the file and Ignore server changes when prompted.

The reason why it failed for you is because you must have the "Get latest version of item on check out" option turned on. Turn this option off by going to Tools...Options...Source Control...Visual Studio Tema Foundation Server and unchecking "Get latest version of item on check out"

Cheers

Happer
Yeah - this worked for me.
teedyay
Just did it this way after struggling 2 hrs w Power Tools and not getting anywhere...wtf is with TFS not supporting this basic functionality...
alchemical
The functionality is added in to TFS 2010 / Visual Studio 2010.
Robaticus
+30  A: 
  1. Download and install Team Foundation Power Tools.
  2. Open up the Visual Studio command prompt
  3. Navigate to the directory on the file system that TFS is mapped to. If you don't do this you'll get an "Unable to determine the workspace" error when you try to roll back
  4. Make sure everything else is checked in or shelved
  5. run tfpt rollback to bring up the interface.
  6. Choose the changesets you want to rollback
  7. Check in the new versions of the files you rolled back

The big disadvantage of the tool is that it will want to refresh everything in your workspace before you can merge. I got around this issue by creating a new workspace just for the rollback which mapped directly to the place in the source tree where the affected files were.

If you need help to figure out which changesets to roll back, I find the code review tool in the free Team Foundation Side Kicks add-in very helpful.

Helephant
+1, these side kicks look cool!
slf
Perfect, very helpful.
Jonathan Moffatt
You can try this way, but be warned, the tools are not well documented, and even if you can get past all the errors, you may or may not be able to really rollback. (I just tried for 2hrs)
alchemical
What errors did you get?
Helephant
The tip about making a new workspace earned a +1 for you
Joel Martinez
+1  A: 

Ben Scheirman - the Changeset Details dialog does not have rollback functionality.

jlo
+8  A: 

Another way to make your option 1 work is to reverse the order of the steps:

  1. Check Out the items
  2. Get Specific Version to the old version
  3. Check in (ignoring the "warning server version is newer" dialog)

This will work even if you have Get Latest On Checkout set.

Dave Roberts
Did not work for me. But that must be because some pinhead set up the TFS with silly policies.
SHODAN
+1  A: 

Another option is TFSPlus. This Visual Studio Addin adds (among others) Get This Version command to the history window. If you have the file checked out it will replace it with that version. If you do a check in afterwards you will effectively do a rollback to that version.

It works on individual files instead of complete changesets, though.

Damir Arh
A: 

using TFS powertools is the best way http://rajputyh.blogspot.com/2008/08/change-set-rollback-using-tfs-power.html

yogee