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

Re: BUG? git stash and immediate git apply results in conflict

From
Chris Torek <chris.torek@gmail.com>
Date
Jun 2, 2022, 06:32 UTC
Message-ID
<CAPx1GvfQLP3q-SvW38=VOxoAmQpMMau_UfXXXQiZSV3NOJCs0w@mail.gmail.com>
In-Reply-To
<CAHHcNoe12h5E9OmkZy03-i7miFg2hLiT04BF3_t9C2bcmduR5Q@mail.gmail.com>
On Wed, Jun 1, 2022 at 2:11 PM Akos Vandra-Meyer <axos88@gmail.com> wrote:
>  git stash -ku
>  git stash pop
This is not a bug in `git stash` itself, but rather in the way you're using it.
There are two mistakes on your part here:

1: You are using `-k`, aka `--keep-index`. This flag is intended for usages that are not yours here.

2. You are *not* using `--index` in your `git pop`.  The `--index` flag is
intended for the kind of thing you are doing here.

It's a bit unfortunate (and perhaps worth some work in the documentation) that the `--keep-index` and `--index` flags sound so similar, and yet are so different. The documentation could use some examples here, I think.

Note that if you *do* want to use `--keep-index` during the `git stash` step, you will need a `git reset --hard` before your `git stash apply --index && git stash drop` step (aka `git stash pop --index`).

Chris
Previous: Akos Vandra-MeyerNext: Akos Vandra-Meyer
Message 2 of 4 in “BUG? git stash and immediate git apply results in conflict”
  1. Akos Vandra-MeyerJun 1, 2022
  2. Chris TorekJun 2, 2022
  3. Akos Vandra-MeyerJun 2, 2022
  4. Chris TorekJun 2, 2022

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.