How can I get my changes back after clicking "Undo pending changes..." in Visual Studio 2013 and TFS

Just for your help. As per stackoverflow's questions link shared. He is trying to say that if you have not build your project. You can open last built dll in Reflector and see the code of the files and recover the code.

You can use any took like Reflector or dotpeek from JetBrains.

Visit this link to know more about dotpeek

But if you have build your project after performing Undo Pending changes then as per my knowledge it is impossible to get the code.


Unbelievable! After giving up and rewriting all of the code I lost, I was able to recover the files. After pressing "Undo pending changes" I never built the solution again. Then, I closed the solution, copied the entire workspace and saved it under a different name. Next, I reopened the original solution. I then used "Add existing item" from the original locations of the files I lost. Then, (and here's the cool part) I navigated to the copied workspace and found the lost files in-tact and in their original locations. Great! I only wish I did this before I rewrote my code!

For me, this solution was found purely by happenstance, but I hope someone else can use this information in the future. Please note that I never built the solution after I undid the changes so that may be the reason why the files were still in their original locations but not visible in the solution itself.


This happened to me today, but it was after I overwrote local changes with an unshelved version. I tried decompiling the dll, but it was too old and didn't have the changes. I finally found the changes in the TFS temporary diff files in "AppData\Local\Temp\TFSTemp". The files all had names like "vctmp4316_370233.cs", but they were all there and thankfully I was able to recover my changes.

Another thing you might try if you have MSTest unit tests is looking for dlls in the solution "TestResults" folder.

The last step is to setup some sort of backup system so this doesn't happen again.