Subject: Re: [PATCH v2] git-stash.txt: Add example "Using stash selectively"

From: Johannes Sixt <[email-masked]>
Date: Thu, 06 May 2010 11:04:36 +0200

Am 5/6/2010 10:40, schrieb Jari Aalto:
> +$ git reset                     # make the index clean
> +$ git add -p A C                # add necessary bits to the index
> +$ git stash save --keep-index   # the remainder goes to the stash

Isn't "the remainder goes to the stash" wrong? I thought that both
worktree changes and index go to stash; only that changes recorded in the
index are not undone in the index and worktree.

> +... test, debug, perfect ...
> +$ git commit
> +$ git stash pop                 # get the remainder back

And here both changes are unstashed, but since the changes that previously
were only in the index are already commited, it looks as if no index
changes were unstashed.

The distinction is important because if you 'stash --keep-index', but then
change your mind and 'reset --hard', you actually do *not* lose data
because the index changes are still in the stash.

Or spelled in a different way: you cannot undo the index changes and keep
only the worktree changes by 'stash --keep-index', 'reset --hard', 'stash
pop'.

-- Hannes