* git stash save --keep-index
@ 2008-07-15 12:31 Sverre Rabbelier
2008-07-15 14:26 ` SZEDER Gábor
0 siblings, 1 reply; 3+ messages in thread
From: Sverre Rabbelier @ 2008-07-15 12:31 UTC (permalink / raw)
To: Git Mailinglist
Heya,
I have switched to using next/ recently and have had the chance to try
out the new '--keep-index' option to 'git stash'. I must say that 'git
stash save --keep-index' in combination with 'git add -p' followed by
'e' allows for a really nice workflow where I can split up patches
very easily, and test them before committing anything. IIUC the
'--keep-index' option was added as a response to the request to
support a workflow something like this:
<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^
Nothing too bad surely, but I thought that the '--keep-index' option
was exactly to prevent having to do:
<hack hack hack>
$ git add # or -i / -p
$ git commit -m "tmp"
$ git stash save
<test if now committed changes were indeed ready to be comitted>
So the '--keep-index' option eliminates the need for such a temporary
commit in the (hopefully) common case where the selected changes were
indeed good, but we still need it in the case that the changes were
not ready / need something from the stashed changes.
Am I missing something here? Or is the only/best solution here to just
alias 'git commit -m "tmp" && git stash pop && git reset HEAD^' to
'git undo-stash'?
PS: It'd be nice if I could do 'git stash --keep-index' since I"m used
to 'git stash' automagically defaulting to 'git stash save'.
--
Cheers,
Sverre Rabbelier
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: git stash save --keep-index
2008-07-15 12:31 git stash save --keep-index Sverre Rabbelier
@ 2008-07-15 14:26 ` SZEDER Gábor
2008-07-15 14:50 ` Sverre Rabbelier
0 siblings, 1 reply; 3+ messages in thread
From: SZEDER Gábor @ 2008-07-15 14:26 UTC (permalink / raw)
To: Sverre Rabbelier; +Cc: Git Mailinglist
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
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: git stash save --keep-index
2008-07-15 14:26 ` SZEDER Gábor
@ 2008-07-15 14:50 ` Sverre Rabbelier
0 siblings, 0 replies; 3+ messages in thread
From: Sverre Rabbelier @ 2008-07-15 14:50 UTC (permalink / raw)
To: SZEDER Gábor; +Cc: Git Mailinglist
On Tue, Jul 15, 2008 at 4:26 PM, SZEDER Gábor <szeder@ira.uka.de> wrote:
> 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'.
Mhhh, ok, I can live with that, thanks!
--
Cheers,
Sverre Rabbelier
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2008-07-15 14:51 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-07-15 12:31 git stash save --keep-index Sverre Rabbelier
2008-07-15 14:26 ` SZEDER Gábor
2008-07-15 14:50 ` Sverre Rabbelier
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.