Re: git stash and manually edited chunks

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Gavin Guo <tuffkidtt@xxxxxxxxx> writes:

>> 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.
>
> I am confusing about the description here. Git stash --keep-index
> exist after editing the hunk, so why stash will save the difference
> between HEAD and A, I think it should be the state which is modified
> by git add -p(using e), and as a result of no conflict.

It's actually both. And indeed, "diff" is slightly oversimplified :
stash saves the state of HEAD and of the index, as two commits. Try
running "gitk --all" after stash to see what's going on.

-- 
Matthieu Moy
http://www-verimag.imag.fr/~moy/
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]