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

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

From
JFJonas Flodén <jonas.floden@gmail.com>
Date
Sep 1, 2008, 23:14 UTC
Message-ID
<B1185033-36D7-4504-92A3-6F75B6CE90DF@gmail.com>
Hello all,

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.

The following sequence should illustrate the problem. Notice how both the b and c are popped from the stash.

git init echo a > test.txt git add test.txt git commit -m "a" echo b >> test.txt git add test.txt echo c >> test.txt git stash save --keep-index git commit -m "b" git checkout -b new_branch HEAD^ git stash pop git diff

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

With regards
Jonas
Next: SZEDER Gábor
Message 1 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.