Know your Tools: IntelliJs Shelve Function

I switched to IntelliJ for half a year now. For backend java development I couldn’t figure out lots of advantages compared to eclipse. It always seems to me like it’s six of one and half a dozen of the other. A few things within moving and renaming classes seems to work better, but therefore I always struggle with the module structure. But yesterday I found my killer feature and I’ll never switch back to eclipse until they have this feature too: Shelving changes.

You may know this feature from git, it’s called git stash or mercurial hg shelve. (If you don’t know it check it out! It’s worth it!) You just put your current uncommitted (maybe not even compiling) changes aside to work on a task that cropped up (maybe an important bug fix). I already loved this feature as I learned it in git. In IntelliJ you just click “Shelve Changes..” in the “Changes” view, select all changed files you want to shelve and IntelliJ creates a patch in your “Shelf” (a tab in the “Changes” view).

After you are done with the other tasks, you can unshelve your previous work, again by right clicking on the files in your shelf and selecting “Unshelve changes”. You don’t even need to unshelve all at once. You can also select “Unshelve…” and select only a few files you want to unshelve. If you do so the patch in your shelf stays untouched. If you want to remove the unshelved files from it you need to do it manually. For more details have a look at the IntelliJ documentation.

So if you didn’t know this feature, try it! And if you know an equivalent feature in eclipse, please let me know!

One Response to “Know your Tools: IntelliJs Shelve Function”

  1. Sam Atkinson says:

    It’s interesting you like this so much. Shelving always scared me, because it’s an abstraction IntelliJ provides over git. I’ve always just chosen to rely on git to try and reduce the number of issues.

    My workflow; I work on local branches. So I’ll be working on a JIRA on a local branch, then if something comes up I commit, switch to master (which is clean) then I can work on whatever just came up. This also makes it really easy for merging; I can pull down to master, then merge my local branch over the top and push. If something goes massively wrong then my code is still protected on my branch.