<p>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:</p>
<h3>Option 1: Get Prior Version</h3>
<ol>
<li>Manually get prior version of each file</li>
<li>Check out for edit</li>
<li>Fail - the checkout (in VS2008) forces me to get the latest version</li>
</ol>
<h3>Option 2: Get TFS Power Tools</h3>
<ol>
<li>Download Team Foundation Power Tools</li>
<li>Issue rollback command from cmd line</li>
<li>Fail - it won't work if there are any other pending changes</li>
</ol>
<h3>Option 3: Manually Undo Changes</h3>
<ol>
<li>manually undo my changes, then commit a new changeset</li>
</ol>
<h3>Question</h3>
<p>How do I rollback to a previous changeset in TFS?</p>

[{'answer_id': 32614, 'author': 'Ben Scheirman', 'author_id': 3381, 'author_profile': 'https://Stackoverflow.com/users/3381', 'pm_score': 2, 'selected': False, 'text': '<p>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).</p>\n\n<p>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.</p>\n\n<p>Where do I downmod TFS on this site?</p>\n'}, {'answer_id': 32885, 'author': 'Phillip Wells', 'author_id': 3012, 'author_profile': 'https://Stackoverflow.com/users/3012', 'pm_score': 2, 'selected': False, 'text': '<p>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 <a href="http://www.codeplex.com/VSTSGuidance/Wiki/View.aspx?title=How%20to%20undo%20a%20check-in&amp;referringTitle=Source%20Control%20Practices%20at%20a%20Glance" rel="nofollow noreferrer">http://www.codeplex.com/VSTSGuidance/Wiki/View.aspx?title=How%20to%20undo%20a%20check-in&amp;referringTitle=Source%20Control%20Practices%20at%20a%20Glance</a> for more information.</p>\n'}, {'answer_id': 34633, 'author': 'Ben Scheirman', 'author_id': 3381, 'author_profile': 'https://Stackoverflow.com/users/3381', 'pm_score': 3, 'selected': False, 'text': '<p>Ahh, just found this <a href="http://www.codeplex.com/VSTSGuidance/Wiki/View.aspx?title=Use%20Team%20Foundation%20Power%20Tools%20to%20Rollback%20a%20Change&amp;referringTitle=Source%20Control%20Guidelines" rel="noreferrer">CodePlex Article on using TFPT.exe</a> (power tool) to rollback a changeset.</p>\n\n<p>Hope this helps you out.</p>\n'}, {'answer_id': 343999, 'author': 'Happer', 'author_id': 43651, 'author_profile': 'https://Stackoverflow.com/users/43651', 'pm_score': 5, 'selected': False, 'text': '<p>Your solution #1 will work:\n1. manually get prior version of each file</p>\n\n<ol start="2">\n<li><p>check out for edit</p></li>\n<li><p>Checkin the file and Ignore server changes when prompted.</p></li>\n</ol>\n\n<p>The reason why it failed for you is because you must have the \n"Get latest version of item on check out" option turned on.\nTurn 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"</p>\n\n<p>Cheers</p>\n'}, {'answer_id': 638425, 'author': 'Helephant', 'author_id': 13028, 'author_profile': 'https://Stackoverflow.com/users/13028', 'pm_score': 6, 'selected': False, 'text': '<ol>\n<li>Download and install <a href="http://www.microsoft.com/download/en/details.aspx?displaylang=en&amp;id=15836" rel="noreferrer">Team Foundation Power Tools</a>. </li>\n<li>Open up the Visual Studio command prompt</li>\n<li>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</li>\n<li>Make sure everything else is checked in or shelved</li>\n<li>run tfpt rollback to bring up the interface. </li>\n<li>Choose the changesets you want to rollback</li>\n<li>Check in the new versions of the files you rolled back</li>\n</ol>\n\n<p>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. </p>\n\n<p>If you need help to figure out which changesets to roll back, I find the code review tool in the free <a href="http://www.attrice.info/cm/tfs/" rel="noreferrer">Team Foundation Side Kicks</a> add-in very helpful.</p>\n'}, {'answer_id': 1267809, 'author': 'jlo', 'author_id': 48148, 'author_profile': 'https://Stackoverflow.com/users/48148', 'pm_score': 2, 'selected': False, 'text': '<p>Ben Scheirman - the Changeset Details dialog does not have rollback functionality.  </p>\n'}, {'answer_id': 1376694, 'author': 'Dave Roberts', 'author_id': 144978, 'author_profile': 'https://Stackoverflow.com/users/144978', 'pm_score': 4, 'selected': False, 'text': '<p>Another way to make your option 1 work is to reverse the order of the steps:</p>\n\n<ol>\n<li>Check Out the items</li>\n<li>Get Specific Version to the old version</li>\n<li>Check in (ignoring the "warning server version is newer" dialog) OR on the conflicts section of the Pending Changes dialog resolve the conflicts by keeping the local version.</li>\n</ol>\n\n<p>This will work even if you have Get Latest On Checkout set.</p>\n'}, {'answer_id': 1958627, 'author': 'Damir Arh', 'author_id': 197913, 'author_profile': 'https://Stackoverflow.com/users/197913', 'pm_score': 2, 'selected': False, 'text': '<p>Another option is <a href="http://tfsplus.codeplex.com/" rel="nofollow noreferrer">TFSPlus</a>. 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. </p>\n\n<p>It works on individual files instead of complete changesets, though.</p>\n'}, {'answer_id': 3311783, 'author': 'yogee', 'author_id': 399424, 'author_profile': 'https://Stackoverflow.com/users/399424', 'pm_score': 2, 'selected': False, 'text': '<p>using TFS powertools is the best way <a href="http://rajputyh.blogspot.com/2008/08/change-set-rollback-using-tfs-power.html" rel="nofollow noreferrer">http://rajputyh.blogspot.com/2008/08/change-set-rollback-using-tfs-power.html</a></p>\n'}, {'answer_id': 4086608, 'author': 'PJUK', 'author_id': 433049, 'author_profile': 'https://Stackoverflow.com/users/433049', 'pm_score': 1, 'selected': False, 'text': '<p>None of these solutions quite worked for me Dave Roberts solution was the closest to what I actually got working.\nI do not have Get latest version of item on check out enabled, however it seems to be a server policy.</p>\n\n<p>My solution to this is to check the file out for edit, get specific version, then when the conflict is detected use the merge tool (and manually merge none of the changes) so that the file is in the condition it was.</p>\n\n<p>I was going to go with compare with the specific version and copy the entire file then just paste it over the top of the old one.</p>\n\n<p>Still there should be an easier way to do this!</p>\n'}, {'answer_id': 4168886, 'author': 'CamelBlues', 'author_id': 506238, 'author_profile': 'https://Stackoverflow.com/users/506238', 'pm_score': 3, 'selected': False, 'text': '<p>Not having a rollback option is actually feature of TFS ;)</p>\n\n<p>To rollback changes:</p>\n\n<ol>\n<li>Check out whatever specific version of changes you want</li>\n<li>Edit->Select All->Copy the text in the file</li>\n<li>Checkout whatever version of the file is on the server</li>\n<li>Paste over the file and check in.</li>\n</ol>\n\n<p>And now all your intermediate changesets before the rollback are saved as well!  What a great feature!</p>\n'}, {'answer_id': 4693704, 'author': 'Guru', 'author_id': 575959, 'author_profile': 'https://Stackoverflow.com/users/575959', 'pm_score': 1, 'selected': False, 'text': '<p>Get <strong>Specific Version</strong></p>\n\n<p>In <em>Version</em> <strong>Type</strong> drop down select Type as <strong>Changeset</strong></p>\n\n<p>Use Changeset ... button to find your Changeset or just type in, if you know this number.</p>\n\n<p>After you have the specific Changeset.</p>\n\n<p>Check Out</p>\n\n<p>Check In</p>\n'}, {'answer_id': 5355837, 'author': 'Kevin Lo', 'author_id': 199043, 'author_profile': 'https://Stackoverflow.com/users/199043', 'pm_score': 4, 'selected': False, 'text': '<p>Rollback has been moved from tfpt.exe to tf.exe, the Team Foundation Version Control Tool.</p>\n\n<pre><code>TF - Team Foundation Version Control Tool, Version 10.0.30319.1\nCopyright (c) Microsoft Corporation.  All rights reserved.\n\nRolls back the changes in a single or a range of changesets:\ntf rollback /changeset:changesetfrom~changesetto [itemspec] [/recursive]\n            [/lock:none|checkin|checkout] [/version:versionspec]\n            [/keepmergehistory] [/noprompt] [/login:username,[password]]\n\ntf rollback /toversion:versionspec itemspec [/recursive]\n            [/lock:none|checkin|checkout] [/version:versionspec]\n            [/keepmergehistory] [/noprompt] [/login:username,[password]]\n</code></pre>\n'}, {'answer_id': 6656802, 'author': 'StarCub', 'author_id': 109027, 'author_profile': 'https://Stackoverflow.com/users/109027', 'pm_score': 0, 'selected': False, 'text': '<p>The solution above is for TFS2008. TFS2010 has built-in rollback feature. see <a href="http://www.edsquared.com/2010/02/02/Rollback+Or+Undo+A+Changeset+In+TFS+2010+Version+Control.aspx" rel="nofollow">this</a> article for details.</p>\n'}, {'answer_id': 6940494, 'author': 'Ruslan', 'author_id': 115466, 'author_profile': 'https://Stackoverflow.com/users/115466', 'pm_score': 3, 'selected': False, 'text': '<p>For reference, if you\'re using <strong>TFS 2010</strong>, here\'s the link to <a href="http://msdn.microsoft.com/en-us/library/dd380776.aspx">Rollback Command (Team Foundation Version Control)</a> manual.</p>\n\n<p>To rollback a particular <strong>changeset</strong>, go to <strong>Visual Studio Command Prompt (2010)</strong>, navigate to your TFS workspace directory, and type in command:</p>\n\n<pre><code>tf rollback /changeset:C12345\n</code></pre>\n\n<p>where <code>12345</code> is your changeset number. After this, it will show you the log of what it did and you\'ll have to sort out merge conflicts.</p>\n'}, {'answer_id': 7124417, 'author': 'Ed Blankenship', 'author_id': 250290, 'author_profile': 'https://Stackoverflow.com/users/250290', 'pm_score': 4, 'selected': False, 'text': '<p>You have two options for rolling back (reverting) a changeset in TFS 2010 Version Control.  First option is using the User Interface (if you have the latest version of the <a href="http://visualstudiogallery.msdn.microsoft.com/c255a1e4-04ba-4f68-8f4e-cd473d6b971f" rel="noreferrer">TFS 2010 Power Tools</a> installed).</p>\n\n<p><img src="https://i.stack.imgur.com/mfKMy.png" alt="Rollback Changeset in UI for TFS 2010"></p>\n\n<p>The other option is using the TFS 2010 version control command-line application:</p>\n\n<pre><code>tf.exe rollback\n</code></pre>\n\n<p>I have information about both approaches on my <a href="http://www.edsquared.com/2010/02/02/Rollback+Or+Undo+A+Changeset+In+TFS+2010+Version+Control.aspx" rel="noreferrer">blog post</a> available here:  <a href="http://www.edsquared.com/2010/02/02/Rollback+Or+Undo+A+Changeset+In+TFS+2010+Version+Control.aspx" rel="noreferrer">http://www.edsquared.com/2010/02/02/Rollback+Or+Undo+A+Changeset+In+TFS+2010+Version+Control.aspx</a></p>\n'}, {'answer_id': 7816079, 'author': 'Evgeniy Berezovsky', 'author_id': 709537, 'author_profile': 'https://Stackoverflow.com/users/709537', 'pm_score': 0, 'selected': False, 'text': '<p>Install the <strong>latest version of the TFS Power Tools</strong> (August 2011), and you can just <strong>right-click on a change set</strong> and select "Rollback Entire Changeset". It doesn\'t get much easier than that.</p>\n\n<p>It\'s available here:\n<a href="http://visualstudiogallery.msdn.microsoft.com/c255a1e4-04ba-4f68-8f4e-cd473d6b971f" rel="nofollow">http://visualstudiogallery.msdn.microsoft.com/c255a1e4-04ba-4f68-8f4e-cd473d6b971f</a></p>\n\n<p>It\'s hinted at under <em>Team Explorer Enhancements</em> on the above page:</p>\n\n<blockquote>\n  <p>New in this release is the ability to [..] easily rollback changes in version control.</p>\n</blockquote>\n'}]
['https://Stackoverflow.com/questions/32607', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/1338/']