简体   繁体   中英

How can I get my changes back after clicking “Undo pending changes…” in Visual Studio 2013 and TFS

Using Visual Studio 2013 and TFS I did a lot of work before checking in. Then I accidentally clicked undo pending changes... thinking it would only apply to one of the projects in my solution. Unfortunately it was applied to all projects. How can I get my changes back?

This question has been asked before link . One person suggested using Reflector to copy the dll. I downloaded Reflector, but I'm unsure how to use it. How would I use Reflector to get my changes back.

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.

I did something similar where I hit undo and it removed files I didn't intend it too. I just hit the show all files icon in the Solution explorer. It made the files visible and then all I had to do was right click and then select Include In Project.

This happened to me today. In my case, I was working on an existing typescript file. Luckily the site was loaded in my browser tab and I didn't refresh the page. So I was able to copy the code from the chrome's dev tool - source.

I got this idea after reaching out to this question, Sharing in case somebody found it useful.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM