Re: git stash and manually edited chunks
- From
Matthieu Moy <matthieu.moy@grenoble-inp.fr>
- Date
- Nov 1, 2010, 16:58 UTC
- Message-ID
- <vpqfwvlkmkv.fsf@bauges.imag.fr>
- In-Reply-To
- <AANLkTik6esqP2EkA6SFmfS0zdokG1iTKXqivA2wnpq=9@mail.gmail.com>
Olivier Verdier <zelbier@gmail.com> writes:
Show 8 quoted lines
> Hi! > I asked a question on stackoverflow > (http://stackoverflow.com/questions/4058372/git-stash-and-edited-chunks) > and someone suggested it might be a bug... > For convenience, I reproduce the question here: > > I occasionally have the following problem, which is reproduced by the > following sequence of commands:
Let's say the state of your working tree here is A (and last commit is HEAD).
> * git add -p my_file > * I edit a chunk *manually* (using e)
Here, the index contains a state which is neither in the working tree nor in the last commit. Let's call this state B.
> * git stash --keep-index
Here, the working tree takes state B.
> * git stash pop
Here, you're trying to apply the stash, which is somehow a diff between HEAD and A, on your tree which is in state B. Hence the conflicts.
If you do a "git reset --hard" before the "git stash pop", you'll come back to state HEAD, and the stash will apply without conflict.
-- Matthieu Moy http://www-verimag.imag.fr/~moy/