Thread (3 messages) flat view 3 messages, 2 authors, 2016-06-15

Re: git stash save --keep-index

From: SZEDER Gábor <hidden>
Date: 2016-06-15 22:44:56

Hi Sverre,

On Tue, Jul 15, 2008 at 02:31:54PM +0200, Sverre Rabbelier wrote:
<hack hack hack>
$ git add # or -i / -p
$ git stash save --keep-index
<test if staged changes are ready to be commited>
$ git commit
$ git stash pop
<lather, rinse, repeat>

But what happens if in the testing phase you detect that the commit is
not ready yet, or even, some of the changes you staged should have
been kept? It would make sense to 'undo' the stash the usual way:
$ git stash pop
But alas, it is not possible to apply on a dirty working directory, so
one has to resort to:
$ git commit -m "tmp"
$ git stash pop
$ git reset HEAD^
If there are unstaged changes in the worktree, then yes, 'git stash
apply/pop' will error out complaining about dirty state.  However, if
there are changes in the index, but no unstaged changes in the
worktree, then apply/pop should work (assuming there are no conflicts,
of course).

So, you won't need that temporary commit, if you have not modified
anything or have added all changes to the index since 'git stash
save --keep-index'.

Gábor
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help