59

Using visual studio 2012 and TFS 2012, I would like to rollback a changeset to the prior one.

Hoppe
  • 6,508
  • 17
  • 60
  • 114

3 Answers3

81

In TFS 2012,

  1. View the history of the thing you want to rollback.
  2. Select the changeset you want to roll back.
  3. Right click on the changset and choose "Rollback".
  4. Check that the pending changes are correct (the rollback command will revert the entire changeset not just the file you selected)
  5. Check in.

In TFS 2010, you can call the tf rollback command from a visual studio command prompt, or you can install the TFS power tools and use the same process as above

James Reed
  • 13,873
  • 51
  • 60
  • 5
    Please help me clarify something, when I select in the explorer an old changeset and then click 'rollback', does it rollback to that changeset or to one before?? – Shimmy Weitzhandler Apr 10 '13 at 01:07
  • 9
    It rolls back the changeset you have selected to the previous one. – James Reed Apr 11 '13 at 11:13
  • 2
    Means any changes after that change set would also be removed? If we are talking about full project and changes are in different files in different change sets? – Tauseef Feb 02 '16 at 20:19
  • In VS 2015, when I select single changeset, I can rollback changes on all files, that were affected by this changeset (by single click). When I select multiple changesets, I can rollback changes just on the file I've selected. What I'm doing wrong? – krzyski Oct 26 '16 at 07:06
  • How to rollback only specific files in a changeset and not entire changeset? Is there a way or shd i get specific dates version of the files i want(Is the only way) ? – Mr.Curious Jun 28 '21 at 07:06
27

In TFS / Visual Studio 2012, you have a few options.

Rollback to a specific version

In Source Control Explorer:

  • Right Click the branch you wish to roll back
  • Click Rollback...
  • Choose Rollback to a specific version
  • Enter the changeset number you wish to roll back to.

Rollback a single changeset (you can do this through the dialog loaded above too)

  • Right click the changeset you wish to rollback
  • Choose Rollback entire changset

Checkin the rollback.

gregpakes
  • 4,465
  • 29
  • 43
-9

I have never worked with TFS 2012 but this works in 2010

Get specific version and pick the version you want to roll-back to and then check in that code again.

double-beep
  • 5,031
  • 17
  • 33
  • 41
  • 2
    This is not a rollback. This is a check-in. – Quality Catalyst Jan 12 '15 at 22:34
  • It is not just check in @QualityCatalyst. When you roll back change set X, if you want to save the undoing, after rolling back, you should check in to have the solution without changes in change set X. – Fery Feb 24 '15 at 17:31
  • @Fery, you are right. The answer here though does not talk about a rollback. It talks about a pure check-in based on historic code. – Quality Catalyst Feb 24 '15 at 19:27
  • @QualityCatalyst yeah , you are right. Today I just release for rolling back you can not get a version and then check in, you must roll back a/ to change set then check in. – Fery Feb 24 '15 at 22:52