Reputation: 1423
I have shelved my 26 Java file changes via Intellij Idea 2016.2.1 and I checkout to a different branch.
When I came to the old branch to check my shelved changes.
I have gone mad now, I lost all the files. I worked for nearly two months.
Can somebody help me get it back?
Upvotes: 48
Views: 25662
Reputation: 1189
Even there isn't Shelf tab in IDE you can find shelved changes as patch files at:
{ProjectName}/.idea/.idea.{ProjectName}/shelf/.idea/shelf
Then your can apply any selected patch.
Upvotes: 77
Reputation: 817
I've also experienced this bug repeatedly and hence no longer use shelved changes, but rather the Git CLI directly. As of 2022 Jetbrains IDE's still cannot be trusted with their "Smart Checkout" feature, which has a small probability of the total loss of your files (experienced personally in both IntelliJ & Rider).
Unlike another comment here regarding using the Local History, this did not work for me as the history showed nothing. I've also lost many hours of work due to this bug which remains unfixed.
The solution is to use "git stash -u" on the command line, then checkout the desired commit. Once youre done, type "git stash apply" to restore your files. Trusting the "smart checkout" feature is like playing Russian roullette. It's IDE magic that may just fail and you lose everything.
Upvotes: 1
Reputation: 2658
Maybe this will help someone: I lost part of my shelved changes in combination with an update of IntelliJ. I'm not sure if the update was the reason but eventually most of my most recent (and important) changes were gone. I couldn't restore them from local history as this does not "survive" an update of IDEA. But in the files I saw that there still is some data: C:\Users\myUser\AppData\Local\JetBrains\IntelliJIdea2021.2\LocalHistory had a changes.storageData with ~50MB. Copying the files to the folder of the new version didn't help as the files got overwritten again.
Solution: I was able to get the old version of IntelliJ (2021.2) here and installed it. This can be done in parallel, without removing the newer version. Here I was able to retrieve my changes from the Local History and shelve or apply them again.
Hint: Backup the "Local History" folder (or the whole IntelliJIdea20xx.x folder) before you start. I don't remember if I had to copy it in there again or if it worked out of the box. (Just to be sure the local history doesn't get lost).
Upvotes: 1
Reputation: 121
Andrei's answer was helpful for my situation where I renamed my project and my previously shelved changes were no longer found under the shelf, but I did run into an issue when applying the patch file because I was prompted to "Select missing base" for various files in the patch. Similar to what is seen in the screenshot below:
https://youtrack.jetbrains.com/issue/IDEA-183910
I was able to avoid having to "Select missing base" for various files by first changing the default shelf location and then applying the patch.
https://www.jetbrains.com/help/idea/shelving-and-unshelving-changes.html#change-shelve-location
Also, I found my patch in this location:
{ProjectName}/.idea/shelf
instead of the aforementioned location:
{ProjectName}/.idea/.idea.{ProjectName}/shelf/.idea/shelf
Upvotes: 4
Reputation: 633
I was able to view lost changes and revert back to them by:
Note in my case Git>VCS Operations>Show History showed nothing. Only through the Project Files menu.
Upvotes: 15
Reputation: 2814
You can restore the state of those files if they were edited in IntelliJ. Use local history to see all the changes made in IntelliJ (VCS -> Local History -> Show History).
Upvotes: 36