git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: git stash save --keep-index

From
SZEDER Gábor <szeder@ira.uka.de>
Date
Jul 15, 2008, 14:26 UTC
Message-ID
<20080715142615.GI8224@neumann>
In-Reply-To
<bd6139dc0807150531k4f0a1a4yee2c8ec2b98ee39c@mail.gmail.com>
Hi Sverre,
On Tue, Jul 15, 2008 at 02:31:54PM +0200, Sverre Rabbelier wrote:
Show 17 quoted lines
> <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
Previous: Sverre RabbelierNext: Sverre Rabbelier
Message 2 of 3 in “git stash save --keep-index”
  1. Sverre RabbelierJul 15, 2008
  2. SZEDER GáborJul 15, 2008
  3. Sverre RabbelierJul 15, 2008

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.