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
Related
I have little question, we have an project and I have made some changes in one file and I need to undo those changes ( I have not checked them ) and I need to get the latest version. If I will go for "Undo pending changes" it will only change my files and will not change TFS files right ?
Yup. Changes are only local until you commit them in tfs.
I have done some work on my code and shelved it, then I had to apply a patch to the code from a shelveset to get things working properly. I then had to fix something else in the code and now wish to make a shelveset, but without the patch, so I want to undo the shelveset that I applied.
Is this possible and if so, how?
Given the state you're currently in: No.
If the original shelveset still exists you could "undo pending changes" then reapply the original shelveset.
There is no local history available to you.
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.
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
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.