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