Thursday, August 14, 2008

Change-Set Rollback using TFS Power Tool (tfpt.exe)

Have you made a booboo by checking in something which you shouldn’t have? If you are using TFS and TFS Power Tools (tfpt in short) installed on your system, you are still good to roll the s#%t back.
Here are the steps that you will need to follow:
1. Install TFS Power Tool. This is recommended as it provides a lot of goodies without which you may see hell some day.

2. ‘Shelve’ all changes, as you will have to ‘undo’ all your changes.

3. Open cmd prompt. Make sure your $path environment variable is configured to find tfpt.exe

4. Change directory to the workspace

5. Give this command: rollback /changeset:{Change-Set Number}
(For example rollback /changeset:39356)

6. It will take latest of all your workspace. This is what I don’t like as it doesn’t work otherwise. It takes some but works…

7. After above step, tfpt has taken older version and all those file will be ready to be check-in with older viersion.. Check-in those and take a tea.

Tip [02/24/2009]: Step 6 may kill you if you are storing huge amount of data into TFS. I advice you to create a new workspace with only required files downloaded. For Example, if your all changes are in '$codebase/folder/subfolder/" then create workspace for $codebase/folder/subfolder/ mapped to local directory C:\for_rollback\ Due to this, step 6 will become very fast.

Powertool help and website: http://msdn.microsoft.com/en-us/tfs2008/bb980963.aspx

5 comments:

Gary said...

What if you have multiple changesets you have to roll back to get back to "stable" changeset. The answer I found out was that I had to repeat steps 1 through 7 listed above for each changeset until I got back to the one I wanted. Hope this helps someone. And please correct me if I didnt it the hard way.

Gary said...

Another issue I ran into is when running multiple instances of TFS. If you happen to be pointing to different TFS servers then you might end up with "Unable to Determine Workspace" message. Be sure you close down other VS instances and that you have the correct workspace selected and you are pointed to the correct TFS server.

Yogee said...

Thanks Gary. The same issue may come when your command prompt is not the right directory (i.e. 4th step). Good finding :)

Anonymous said...

I believe there is a typo on Number 3 in the instructions above. The TFS Power Tools application is actually "tfpt.exe" and not "tpft.exe".

This article was VERY helpful once I realized that I was typing the application name wrong.

Thanks!

Yogee said...

Thanks! I've corrected the spelling.