How to revert (Roll Back) a checkin in TFS 2010

TfsRollback

Tfs Problem Overview


Can anyone tell me how to revert (roll back) a checkin in TFS 2010?

Tfs Solutions


Solution 1 - Tfs

You have two options for rolling back (reverting) a changeset in Team Foundation Server 2010 Version Control. First option is using the User Interface (if you have the latest version of the TFS 2010 Power Tools installed).

Rollback Changeset in UI for TFS 2010

The other option is using the TFS 2010 version control command-line application:

tf.exe rollback

I have information about both approaches on my blog post.

For Team Foundation Server 2012, 2013, or Visual Studio Online, rollback is now built-in directly to Source Control Explorer and when you are opening a changeset's details in the Team Explorer Window. You do not need to install any release of the Power Tools for this functionality when using Visual Studio 2012 or later. There is a great MSDN article discussing details about rolling back a changeset now available here: http://msdn.microsoft.com/en-us/library/ms194956(v=vs.110).aspx

Solution 2 - Tfs

For 2010, use the rollback command from the command line. There is not integrated support in the IDE for this, as of yet.

Rollback command

Basically, the way that it works is that it creates an "anti-delta" to negate the impacted changeset. You can accomplish the same thing manually by doing a Get Specific Version, adding a space to the file so it looks like it changed, and checking it in. I still go the latter route to back out a change if I need to for a single file, as I find it quicker to do.

Solution 3 - Tfs

Without using power tools or command line:

  1. ensure Tools->Options->Source Control->Visual Studio Team Foundation Server UNCHECK Get latest version of item on check out
  2. View the history of project folder in Source Control Explorer and right click on the changeset to roll back to and choose Get This Version
  3. Check out for edit on the project folder in the Source Control Explorer (this should keep your local version you just got from the history)
  4. Check in pending changes on the project folder in the Source Control Explorer
  5. if visual studio asks you to resolve conflicts, choose keep local and attempt check in of pending changes on the project folder in Source Control Explorer again

Solution 4 - Tfs

Rolling back changes for another user

If you are attempting to rollback changes for another user, make sure you get latest on the files you are attempting to rollback; otherwise you will see the error:

> "No changes to roll back."

Solution 5 - Tfs

You can rollback a changeset (in TFS2010) through command line doing:

  1. Open CMD or Visual Studio Command Prompt
  2. Change directory to your workspace folder. Example: cd C:\myWorkspace
  3. Run following tf command (where 123 is changeset number)
    C:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\IDE\tf.exe" rollback /changeset:123 /recursive
  4. Go to Pending Changes window to check files marked with edit,rollback and do a Check In.
    pending changes example after a rollback operation

Note: you must use tf.exe full path even in Visual Studio Command Prompt to avoid "Unable to determine the workspace" error. More info here

>Rollback reference (TFS 2010)
https://msdn.microsoft.com/en-us/library/dd380776(v=vs.100).aspx

Solution 6 - Tfs

There is no undo option in TFS (up untill 2008, I haven't used 2010 yet). There are some command line power tools you can use to rollback changes that may help:

http://msdn.microsoft.com/en-us/library/ms194956%28VS.80%29.aspx

HTH

Solution 7 - Tfs

right click file in Visual Studio and Source Control/View History then select last changeset, right click and click Rollback After rollback done, you should check in again.

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestiondevlifeView Question on Stackoverflow
Solution 1 - TfsEd BlankenshipView Answer on Stackoverflow
Solution 2 - TfsJoseph FerrisView Answer on Stackoverflow
Solution 3 - TfsgeerView Answer on Stackoverflow
Solution 4 - TfsSeth FlowersView Answer on Stackoverflow
Solution 5 - TfsdigiogoView Answer on Stackoverflow
Solution 6 - TfsDannyLaneView Answer on Stackoverflow
Solution 7 - TfsSalimView Answer on Stackoverflow