Git Stash vs Shelve in IntelliJ IDEA/Netbeans

Question

I am very unfamiliar with the shelve aspect of Git (EDIT: not an aspect of Git, but rather IntelliJ IDEA feature of shelve).

If stash is used to put aside unfinished work what is shelve then? What would you use it for?

For example on Update Project (from VCS menu)

Update Project option

one will get (in IntelliJ IDEA 2019.2)

Update Project prompt window

Answer

git shelve doesn't exist in Git.

Only git stash:

  • when you want to record the current state of the working directory and the index, but want to go back to a clean working directory.
  • which saves your local modifications away and reverts the working directory to match the HEAD commit.

You had a 2008 old project git shelve to isolate modifications in a branch, but that wouldn't be very useful nowadays.

As documented in Intellij IDEA shelve dialog, the feature "shelving and unshelving" is not linked to a VCS (Version Control System tool) but to the IDE itself, to temporarily storing pending changes you have not committed yet in changelist.

Note that since Git 2.13 (Q2 2017), you now can stash individual files too.

Git is not working after macOS update ("xcrun: error: invalid active developer path (/Library/Developer/CommandLineTools")

Git undo local branch delete