Using Shelves for Storing Local Changes
Suppose a brilliant idea strikes you, when it is too risky or too late in the process to try implementing it straight away… or you want to share a new version with your teammates, or have it reviewed. This is when IntelliJ IDEA’s version control integration helps you move part of your work out of the way so you can continue developing a safe version, while your pending changes are preserved as a shelveset for later use.Let’s consider the following example: several classes in a package are changed, but you want to set aside only one of these files, in our case GraphBuilderImpl.java.
You can see the changed files in the Local tab of the Changes tool window:
Right-click the file you want to set aside, and choose Shelve Changes on the context menu:
The Shelve Changes dialog shows you all the contents of the changelist. The file in question is already checked. If by chance you change your mind and would like to put more files on the same shelf, you can do it right here. Type the optional comment that will identify the new shelveset in addition to its timestamp, and click the Shelve Changes button.
Now, what happens when you click the Shelve Changes button? IntelliJ IDEA creates a shelveset, marks it with a timestamp and comment (if any), and displays in the Shelf tab of the Changes tool window. As your work goes on, you will need to integrate the shelved changes back into your source code. To do that, right-click the shelveset (or one of the revisions within it) in the Shelf tab of the Changes tool window, and choose Unshelve Changes on the context menu:
Next, specify to which changelist you want the revisions restored. Choose one of the existing changelists, or create a new one.
The revisions to be restored appear in the specified changelist in the Local tab of the Changes tool window. Now you can commit changes as you usually do it.
(Note: Opinions expressed in this article and its replies are the opinions of their respective authors and not those of DZone, Inc.)