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

Re: defaulting git stash to "--keep-index"

From
Nathan Collins <nathan.collins@gmail.com>
Date
Nov 20, 2013, 02:08 UTC
Message-ID
<CAO8RVvdMD+xWrkwk+9Nbm7oyTTkc50PURxJe67ygkkTN-L41zw@mail.gmail.com>
In-Reply-To
<20131119195009.6d4e183b@bigbox.christie.dr>
On Tue, Nov 19, 2013 at 5:50 PM, Tim Chase <git@tim.thechases.com> wrote:
> Having lost "add -p" work enough times when stashing, I finally
> dug into the docs to see how to prevent it, discovering that
> "--keep-index" does exactly what I want.

Note that 'git stash (pop | apply) --index' will reinstate the index as it was at stash time, regardless of whether '--keep-index' was used to create the stash. In other words, your index is not "lost" when you stash.

Also note: when you 'git stash --keep-index', although your index remains intact, the changes in the your index still become part of the stash. Hence, any changes to the indexed portion of your files after a stash usually result in a conflict on subsequent 'git stash pop'. This confuses me quite a lot, since I'd expect a main use case of 'git stash --keep-index' to be fixing a up a commit, but then any fixes cause a conflict :P

Cheers,
-nathan
Previous: Tim ChaseNext: Jason St. John
Message 2 of 3 in “defaulting git stash to "--keep-index"”
  1. Tim ChaseNov 20, 2013
  2. Nathan CollinsNov 20, 2013
  3. Jason St. JohnNov 20, 2013

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.