Shelving Changes

Imagine that you’ve been working for a while on a particular feature, and that the code is versioned under Subversion or some other VCS. You’ve made changes in a couple of files but you’re not yet ready to commit. Then suddenly you need to quickly switch to another task because someone in your team needs a bug fixed. Or perhaps, you need to fully switch focus to another feature, because unfortunately someone re-prioritized in the middle of your iteration! This could get messy, especially if the features intersect code-wise. I bet you have (at least some time during your career) copied the modified files to a location outside your project for storage, and then merged them manually when the time came to start working on the feature again (it’s OK, noone can see you nod :-)).

A decent way of solving this situation in IntelliJ, is to use the neat little feature Shelve Changes. It works sort of like an extra local layer of VCS. Just go to the Changes tab, right-click your modified files and then Shelve the Changes. This puts them in a shelf on the file system, and removes them from the list of modified files. Now you can continue working as usual, committing and updating your local repo until you want to Unshelve the Changes. Should there then be any conflicts, IntelliJ provides a merge tool.

Obviously, this is even neater if you start using Change Lists properly. Then you have all the modified files grouped under the change list, and you can then easily Shelve the entire change list.

Finally, a word of warning since this type of local versioning is prone to all the usual problems with having local copies. It’s best used in rare cases when options are limited, and you are prepared to potentially losing all the changes due to a system failure.

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>