03 Nisan 2012 Salı 22:22
I made a mistake and deleted a file from TFS. After discovering the mistake I re-added the file, but now it doesn't have it's history. This is a lot of information that I've lost which I'd like to get back.
I followed methods for undeleting a file, which probably would have worked if I hadn't already re-added the file. Now it doesn't show up as a deleted file because a new file is there with the same name.
03 Nisan 2012 Salı 22:58
In Visual Studio try
=> Tools | Options
=> Go to Source Control, Visual Studio Team Foundation Server and check "Show deleted items in source control explorer"
Now go to source control explorer, you should be able to see the deleted file. Right click the file and pick restore, this should get the file and its history back.
Please remember to mark the replies as answers if they help.
05 Nisan 2012 Perşembe 05:18Moderatör
Thank you for your post.
You can make a try of Tarun's method.
Related issues for you to refer:
If anything is unclear, please free feel to let me know.
Lily Wu [MSFT]
MSDN Community Support | Feedback to us
05 Nisan 2012 Perşembe 13:55
You might have to drop down into the command line to pull this off. I also want to say to anyone else that these instructions work for TFS 2005 and 2008 only -- our item model has changed in TFS 2010 and TFS 11.
1. First make a note of where on your local filesystem the file in question is. I'm going to call it C:\MyWorkspace\File.txt.
2. Start up a Visual Studio Command Prompt and cd to C:\MyWorkspace.
3. First we're going to delete your 'new' file -- the one you don't want. tf delete File.txt, and then tf checkin.
4. Next run "tf history /noprompt /slotmode /format:detailed File.txt" -- this should show the entire history of every item that has ever been called File.txt. It should look something like:
add (the original one, the one you want)
delete (the original one, the one you want)
add (the new one)
delete (this is the change we just committed in step 3)
We are going to undelete the first item that you deleted. But if we say "tf undelete File.txt" it is not clear whether we are talking about the first item or the new one. To disambiguate we are going to specify the Deletion ID of the first file.txt. The deletion ID is specified in the output from the tf history command we just ran. If you look at the first "delete" on the item in the history, then the file path is going to have a deletion ID on the end of it. It will look something like
Either way, the key part we are looking for is the X65. The newer item (the one you don't want) will have a deletion ID, too -- a larger one (higher number).
5. Type "tf undelete File.txt;X65", replacing the 65 with the actual deletion ID from the changeset I put in bold above. This should bring back the File.txt you want. You can check this change in from the command line or from Visual Studio.
Hope this helps
- Yanıt Olarak İşaretleyen Gastroman 13 Nisan 2012 Cuma 15:58
13 Nisan 2012 Cuma 16:00This is exactly what I needed! There is information on how to undelete a file that has been deleted, but not how to undelete something that has then been re-added and deleted again. Thanks so much!