How to get a previous version of a file
I need to get a previous version of a file in source control, using Team Foundation Server (TFS), . When I try to get a specific version based on change set the merge screen comes up. I do not want this开发者_开发知识库, I just want to get the previous version and have it checked out. My current version of the file got corrupted and now I just want the previous version.
Ah, it sounds like you want to rollback (that is, remove some checkins from TFS' history). There is not a built-in way to do this with TFS. However, you can use the TFS Power Tools to accomplish this (there is a tfpt rollback
command).
In practice, the rollback
command just does what you're trying to do. To do it manually, get the version that you want (without checking out the file). Save that somewhere else, then check the file out (which will perform a "get latest" command). Then overwrite that version with the version that you saved elsewhere.
Alternatively, there's a setting in the TFS settings to "Get latest version of item on check out," which may be the cause of all of your problems. It's located in Tools->Options, under Source Control->Visual Studio Team Foundation Server. If that's checked for you, try unchecking it and seeing if it'll let you do what you're trying.
On the merge screen, you should be able to choose to overwrite your local copy with the server version. That sounds like what you want to do.
However, the merge screen should only show up if you have pending changes. If you undo your pending changes on the file, the Get Specific Version command shouldn't cause a merge.
Hmm maybe I am doing something else wrong. I check the file out, then I do get specific version, enter the changeset number, I do not check either of the overwrite check boxes. I get the merge screen, I tell it to overwrite local copy. It does this, but then it undoes my check out and says I do not have the latest on my local computer. If I checkout at this point it ovewrites my previous version with the latest.
精彩评论