Thanks for the info.  Neither "--rebase-merges" nor "--preserve-merges" can 
prevent the changes made by "git commit --amend" against merge commit from 
being lost. The only solution to recover the lost code is to make use of 
"git reflog". 

在 2019年10月18日星期五 UTC+8下午5:36:08,Mikko Rantalainen写道:
>
> On Fri, 18 Oct 2019 at 11:59, Benjamin <wangcha...@gmail.com <javascript:>> 
> wrote:
>
>> This could be an issue of git. The exact steps to reproduce this issue 
>> are as below,
>>
>>     $git merge master
>> ...
>>    $git rebase -i e705c6a dev1  # e705c6a is the ancestor commit of 
>> branch dev1
>>    In the interactive rebase page, Keep using "pick" for the first 
>> commit, and use "s" for all other commits. 
>> 5. You will find that the changes made in step 3 are lost.
>>
>
> I'd suggest doing `git help rebase` and reading about `--preserve-merges` 
> and section "BUGS". Short quotation:
>
>        -p, --preserve-merges
>>            Recreate merge commits instead of flattening the history by
>>            replaying commits a merge commit introduces. Merge conflict
>>            resolutions or manual amendments to merge commits are not
>>            preserved.
>>            This uses the --interactive machinery internally, but 
>> combining it
>>            with the --interactive option explicitly is generally not a 
>> good
>>            idea unless you know what you are doing (see BUGS below).
>
>
> and
>  
>
>> BUGS
>>        The todo list presented by --preserve-merges --interactive does not
>>        represent the topology of the revision graph. Editing commits and
>>        rewording their commit messages should work fine, but attempts to
>>        reorder commits tend to produce counterintuitive results.
>
>  
> In short, doing interactive rebase with merges is always a bit hard. 
> Trying to combine that with squash is asking for trouble.
>
> If you really want to do the merge and squash combined, I think you can 
> start with your current final code with "incorrect" history, do a `git 
> reset --soft $MERGESHA1` and then `git commit --amend`. If you already lost 
> the "final code", `git reflog` will be your friend.
>
> -- 
> Mikko
>
>

-- 
You received this message because you are subscribed to the Google Groups "Git 
for human beings" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to git-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/git-users/b303b88c-7022-4aeb-97b1-b5da55e96586%40googlegroups.com.

Reply via email to