Tuesday, March 20, 2012

Rollback a changeset in TFS 2010

Hello World,

I guess each one of us has this "bad hair day" when you just can't get things right. On one such day, I checked in some code to TFS just to realise while testing that I have broken stuff! Now, I came from a background in VSS and SVN as SCM (Software Configuration Management) systems and they both had an option to "Rollback" to the previous version so you could just undo any malaise you may have caused.
I was taken aback when I did not see this option in the context menu in TFS if I right clicked a changeset upto which things were working. One of my colleagues suggested the following:
  1. Do a "Get Specific" with the changeset upto which everything was fine
  2. Checkout all affected files
  3. Resolve conflicts (there should be some)
  4. Checkin the files
You effectively overwrite your changes with the previous changeset.
Some things to note though:
  • If project and solution files were modified, you may need additional checks to ensure they have been rolled back
  • Sometimes, you may need to make some changes so that TFS detects that the files have changed (e.g. add a space at the end of a codefile
Turns out, there is another way to do a rollback through the TF commandline tool (using VS command prompt) as detailed in MSDN although, as the comments at the bottom suggest, you may need to change directory to your workspace.

Happy Coding!

No comments:

Post a Comment