BUG? git stash and immediate git apply results in conflict
- From
- Akos Vandra-Meyer <axos88@gmail.com>
- Date
- Jun 1, 2022, 06:55 UTC
- Message-ID
- <CAHHcNoe12h5E9OmkZy03-i7miFg2hLiT04BF3_t9C2bcmduR5Q@mail.gmail.com>
Hello!
I believe there might be a bug in how a git stash is calculated with the -k flag. I would expect to always be able to stash and pop a set of changes, but if the working directory contains staged and unstaged changes for a file, this results in a conflict.
The stashed diff shows the changes from the last commit, rather than what is in the current working directory, so when the stash is applied it results in a conflict, because there are staged changes in the current working directory.
Steps to reproduce:
mkdir test cd test git init . echo foo > a echo bar >> a echo baz >> a git add a git commit -m "initial" cat a | sed s/bar/foo2/ > a2; mv a2 a git status git add a cat a | sed s/foo2/xxx/ > a2; mv a2 a git status git stash -ku git stash pop
Thanks for looking into this, Akos Vandra-Meyer