Rollback a single file in TFS - tfs

If I view the history of a single file in source control I can right hand click a change-set in the list and choose "rollback back entire change-set".
Will this rollback all the other files I checked in during that checkin or just the file I am currently viewing? If it does rollback all files is there a way to rollback just the file selected?
Thanks

As previously mentioned, rolling back the changeset rolls it back in its entirety.
Installing Team Foundation Power Tools (which I think pretty much everyone should install) gives you another option: If you want to rollback a single file, you can right click a single file in the Source Control Explorer and select Rollback...

Yes, rolling back the entire changeset will roll back all the changes in it.
However, a Rollback is not instant, when you click that option the rollback will be perform a reverse merge and leave the changes in your workspace. So you can look at them in Pending Changes.
In your case, just perform the Rollback and then undo everything except the file you actually want to Rollback.

From now on, in visual studio 2015 atleast, you can just go to source control, right click a file and choose Rollback.. This will ask you what changeset you would like to rollback for this file and it will only rollback that file.

Very simple workaround :)
1. rollback entire changeset
2. undo all file except file you actually want.

Related

Get the rollback information of a changeset

as it's described in here;
I installed tfs power tools 2012. I used rollback feature by selecting the changeset: thus I'm expecting to rollback to that version and it's working great. When I look at the history of the file that was rollbacked at the "Change" column it's written "edit, rollback"; which is cool.
However I cannot see "which version it has been rollback to". So before rollback I can select the version but later on when I wanted to see "which version it has been rollback to" I can't. Is there a way to find out that information?
Rollback is non destructive so rollback will undo the checkin ( change set ) and then the previous change set is checked in as a normal checkin. There is no reall reason to differentiate between a rolled back checkin and a normal one.

TFS Override the latest change

I have a file that was checked in and is part of a C# project. However, this file is incorrect and it overwrote the previous change which was correct. I need the latest change of this file to revert back to the previous changeset, and I need the previous changeset to be the latest change.
How do I do that?
You can roll back to the previous changeset. This option is only available from the commandline.
tf rollback /toversion:VersionSpec ItemSpec [/recursive] [/lock:none|checkin|checkout] [/version:versionspec] [/keepmergehistory] [/login:username,[password]] [/noprompt]
Alternatively, use Get Specific Version (check all the boxes to override the files) to get the version of the file you want, check the file out and check it back in again. When prompted to resolve merge conflicts, select use local version. This will create a new version on top of the incorrectly checked-in one.
If you install the TFS Power Tool, you can roll back the changeset. With the Power Tool installed, you can do this in the GUI. Select the changeset in a history list, and right click and select Rollback entire changeset.
Here's a nice article:
http://www.edsquared.com/2010/02/02/Rollback+Or+Undo+A+Changeset+In+TFS+2010+Version+Control.aspx
From this article:
You find the TFS Power Tool here: http://visualstudiogallery.msdn.microsoft.com/c255a1e4-04ba-4f68-8f4e-cd473d6b971f

Is there a way to clear all of my TFS pending changes?

If I unshelve a shelveset, the "Pending Changes" toolwindow in Visual Studio will restore the files, the commit comment, and the associated work items I had set up when I shelved.
If I change my mind and decide I'm not ready to work on this shelveset right now -- for example, if I have to drop everything and fix a bug -- is there any way I can clear all of this state at once?
It's easy for me to highlight all the files, right-click, and "Undo". But that only reverts the files; I still have to go in and erase the comment, then switch to the Work Items page, possibly select a different query to make sure I see the work item that I was associated with, and uncheck the box.
Is there a button, menu item, or VS extension that will let me revert the file changes and the commit comment and the list of work items, all at once, and leave me with a totally clean slate to work on something else?
I am not at the office to check this out, but it's worth a shot: Shelve your changes into a new shelveset, keeping in mind to uncheck the "Preserve pending changes locally".
In the next version of Visual Studio it will be a much nicer experience. Check out the session by Jamie Cool on this topic

How can I undo a changeset rollback in TFS 2010?

I accidentally rolled back an entire changeset. How can I undo that operation, and restore the changeset?
If you select "Rollback Entire Changeset" in TFS, it changes the local files so that the changes made in the changeset are reversed.
Since this is a local change and does not take effect until you check the changes in, you can "undo" the rollback by using "Undo pending changes" on your project. Note this will also mean any other uncommitted changes would also be lost, so use with care.
You can always "View History" and retrieve a particular Changeset...
Get the Latest version and Rollback the earlier roll-backed change set and now they get checked out and now check in the changes after required modifications.
Alternatively you can use the following command in visual studio command window:
tf rollback /changeset:changeset_number

TFS shows some pending changes under my name, but I have not changed anything

TFS shows some pending changes under my name, but I have not changed anything. When I check in and see View Pending changes, I see some of the changes which I have never made, changes pending under some other user might be shown as my pending changes. When I unselect and check-in my changes, these are still locked under my name? Is this due to auto-checkout or any other reason? (TFS policy requires a compile before check-in)
This is probably due to the automatic checkout feature in TFS.
TFS uses an atomic check-in process and is very careful about recording who did what. When you start editing a file (or the IDE edits one on your behalf, for example a .csproj or .vbproj file) then the file will show up in your pending changes list to show you that you have the file checked out with an edit pending.
To see your pending changes list, go to View, Other Windows, Pending Changes in Visual Studio.
To check-in any pending changes you can right click on the file in solution explorer or you can select it in the pending changes view. Only then will the change be committed into version control. From the pending changes view you can compare with the server version to see what changes you have made.
To see the changes that have been committed to the server you can right click on a file or folder and select "View History".
If you want to remove the pending change and restore the file to what it was before you edited it you can right click on the file and select "Undo Pending Changes".
If you want to change the auto check-out behaviour to prompt you before it performs a check-out, then go to Tools, Options, Source Control, Environment and change the Checked-in items for Saving and Editing to "Prompt for check out" rather than the default which is "Check out automatically".
Hope that helps,
Martin.
I've had a similar issue; TFS still says I've got pending changes that when I compare declares as being identical. This post comes up with a way to prune out all the identical ones and to leave you with only the files that actually have changed.
The problem might have to do with different workspaces that you use or have used possibly on different computers. Check the workspaces that exist and see if the files are checked out anywhere else. Here the sidekick tool mentioned in a comment can help.

Resources