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

Re: git stash and manually edited chunks

From
OVOlivier Verdier <zelbier@gmail.com>
Date
Nov 2, 2010, 08:37 UTC
Message-ID
<AANLkTiknhRGuBMFEKbVdyN83SiF9j2nNz=v-nMaD-iTb@mail.gmail.com>
In-Reply-To
<vpqfwvlkmkv.fsf@bauges.imag.fr>
Thank you,

but that does not explain why there is a conflict *only* when I edit the chunk manually, does it?

Besides, some people tried to reproduce my problem on Linux and they got no conflict after edited chunks.

So it seems that it could be a bug specific to Mac OS X.
== Olivier
On 1 November 2010 17:58, Matthieu Moy <Matthieu.Moy@grenoble-inp.fr> wrote:
Show 38 quoted lines
> Olivier Verdier <zelbier@gmail.com> writes:
>
>> 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/
>
Previous: Matthieu MoyNext: Matthieu Moy
Message 3 of 6 in “git stash and manually edited chunks”
  1. Olivier VerdierNov 1, 2010
  2. Matthieu MoyNov 1, 2010
  3. Olivier VerdierNov 2, 2010
  4. Matthieu MoyNov 2, 2010
  5. Gavin GuoNov 3, 2010
  6. Matthieu MoyNov 3, 2010

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.