How to restore shelved changes in Intellij when the shelf tab is not shown?
Asked Answered
A

6

16

I tried to use the "shelf" feature for the first time in IntelliJ IDEA today. I shelved all my current changes so that I could work on a quick bugfix, commit it, and come back to my current work afterwards.

When I commited the "shelf" action, IntelliJ created the shelf and I could see it in the tool window. Then it reverted, and reloaded the project.

Now the shelf tab in the Changes tool window does not appear any more.

However in the file system I can see the patch file under .idea/shelf.

Why ? I suspect the problem is that the .idea directory is itself under version control. So when I shelved the changes, it file was included in the shelved changes, and then it was reverted, and IntelliJ is not aware of the shelved changes any more.

I am using Git.

How can I make IntelliJ aware of the patch file in the change tool window ? Or if impossible how can I restore these changes based on the patch file only ?

And how to use this feature in the future without encountering this problem ?

Is it a bad practice to keep the .idea directory in te VCS ?

Artimas answered 19/3, 2015 at 8:56 Comment(1)
For me the branch name was long, I just had to expand the left window to make shelf tab visible :)Kilogram
A
13

The answer to the

How can I make IntelliJ aware of the patch file in the change tool window ?

question was :

  1. Create a bogus shelved change so that the "shelf" tab is available. It will not show if there are currently no shelved changes.

  2. Right click in the "shelf" tab, select "import patch file", pick the previously create patch file. This creates the "shelf"

  3. You can now "unshelf" the changes normally

Finally, I had to manually merge the workspace.xml file. After this, I think I will think about stopping to commit IDE project files to VCS. At least when it is a trivial task to recreate the IDE project from e.g. a checked out Maven project.

Artimas answered 19/3, 2015 at 10:30 Comment(0)
S
2

If you are ever lose the Shelf tab in a Jetbrains IDE, you may have shelved too large of a file (a 1.81 GB .patch in my case). You can view all of your patches in the Jetbrains shelf by going to: /.idea/shelf

Delete the really large patch file and restart the IDEA and the Shelf tab reappears on the Git area Shelf Tab.

If you don't see your .idea folder in your IDE, follow these steps:

  1. Help > Find Action...
  2. Search "Registry" and click the found action See attached screenshot
  3. In the Registry search "dot.idea" and uncheck the checkbox in the Value column for the projectView.hide.dot.idea Key See other screenshot
Snashall answered 18/2, 2022 at 1:55 Comment(0)
H
1

I had similar issues, but shelving bogus changes did not help (was using WebStorm, but the underlaying IDE is the same). The shelf window did not show up no matter what I did. Even though the shelved changes were created in the .idea/shelf folder. What actually in the end helped was moving/deleting .idea folder under the project completely (good to backup before deletion). And restarting JetBrains IDE.

Hyperthermia answered 3/2, 2020 at 12:50 Comment(0)
D
0

For anyone (like me) still running into this issue:

The shelf tab is most likely there, but not displayed due to the width of the commit tab.

In the top right of the commit tab there are 3 icons:

  • arrow down
  • cogwheel
  • minimize

On the ARROW DOWN you see all the "hidden" tabs, which includes the tab "Shelf" for me. Or you make the commit tab wider then you should also see the tabs at the top.

Danelledanete answered 26/10, 2022 at 7:47 Comment(0)
S
0

Click here(down arrow->shelf) and do unshelve the required stash from the list and now they revert back to commit tab

Screenshot

Swick answered 8/11, 2023 at 9:34 Comment(0)
T
0

In my case the Shelf disappeared when PHPStorm crashed soon after I created the patch (it crashed for an unrelated reason). It turned out the XML file describing the patch in [project_folder]/.idea/shelf was missing but the underlyling folder with patch itself was still there. Probably during crash the xml was not created / saved and later PHPStorm didn't have means to figure out the patch details.

Assuming your case is the same or similar (missing XML file for the shelved patch) then the fix is below:

The fix

  1. In a /shelf folder in your project create an xml file with same name as the folder with the patch. I.e. if the patch folder is /shelf/some_patch then create an xml file some_patch.xml
  2. Create content of following structure (or copy, paste and adopt xml content from patches in your other projects):
<changelist name="some_patch" date="1710277912615" recycled="false">
   <option name="PATH" value="$PROJECT_DIR$/.idea/shelf/some_patch/shelved.patch" />
   <option name="DESCRIPTION" value="Some patch description" />
</changelist>

This is for Windows. The folder structure should be adjusted accordingly for other OSes.

Thorman answered 12/3 at 21:30 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.