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

Re: Unexpected behaviour with git stash save --keep-index?

From
SZEDER Gábor <szeder@ira.uka.de>
Date
Sep 2, 2008, 01:28 UTC
Message-ID
<20080902012804.GB6739@neumann>
In-Reply-To
<B1185033-36D7-4504-92A3-6F75B6CE90DF@gmail.com>
Hi,
On Tue, Sep 02, 2008 at 01:14:10AM +0200, Jonas Flodén wrote:
Show 6 quoted lines
> while I was using StGit for the first time and used git stash to split
> the changes into different patches I noticed that git stash save -- 
> keep-index
> will stash also the changes that are already in the index. This was  
> unexpected
> atleast to me but maybe someone can explain why it's correct.

A plain 'git stash [save]' means "save all local modifications and clear both the index and the working tree".

'git stash save --keep-index' means "save all local modifications and remove all modifications from the working tree that are not in the index". This differs substantially from "save only those modifications that are not in the index, and then remove them from the working tree".

> Also maybe someone could someone recommend a way to split an unclean  
> working dir
> into several patches/commits?

The workflow described at the end of stash's man page (under 'Testing partial commits') works well for me.

(Heh, I have just looked that section up, and noticed that the formatting is broken and some comments are missing from the man page. I will send out a patch in a minute.)

Regards, Gábor

Previous: Jonas FlodénNext: SZEDER Gábor
Message 2 of 6 in “Unexpected behaviour with git stash save --keep-index?”
  1. Jonas FlodénSep 1, 2008
  2. SZEDER GáborSep 2, 2008
  3. Documentation: fix disappeared lines in 'git stash' manpageSZEDER Gábor, Sep 2, 2008
  4. Documentation: minor cleanup in a use case in 'git stash' manualSZEDER Gábor, Sep 2, 2008
  5. Jonas FlodénSep 2, 2008
  6. Karl HasselströmSep 2, 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.