Question

I'm working on a project in Visual Studio 2012, that's hosted on TFS.Any way, I don't know if it's due to lack of sleep or sheer carelessness, when trying to move one large function body from one file to another, I copied the declaration to the new file, but forgot to copy the body and then erased the body from the old one, clicked save by reflex and closed the first .cpp file, so when I pasted it in the second one, to my surprised I pasted the declaration and not the definition.Undo pending changes would only undo the 'Add' alltogether.Is there ANY way to retrieve the lost source or should I start rewriting it ASAP?Because I spend quite a while writing it.

Was it helpful?

Solution

View the history of the file. Right click it >> Source Control >> View History, as below:

View History

This obviously assumes you've checked it in at some point.

OTHER TIPS

Under Visual Studio you have several levels of Copy / Paste, so you could have retrieved it by pressing CtrlAltIns (if I remember well).

If you still haven't closed Visual Studio, it might still be in your Copy / Paste ring, it might be worth giving it a try.

Otherwise, you can always rollback to a previous check-in state in your TFS server (if you checked in the code you want before you deleted it).

First, check-in your current state to the server. Then rollback to the previous version that had your code (right click your solution, then Source Control -> Get Specific Version). Now copy your code in a side editor. Re-go to the latest version (Get latest Version... on your solution). Now re-paste your code at the right place and you're done.

If CTRL+Z doesn't work inside VS, go to the empty folder of the deleted files and try CTRL+Z there. Has worked for me several times.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top