Re: Possible bug: git pull --rebase discards local commits
- From
Junio C Hamano <gitster@pobox.com>
- Date
- Aug 23, 2016, 19:28 UTC
- Message-ID
- <xmqqvayruvwk.fsf@gitster.mtv.corp.google.com>
- In-Reply-To
- <1471969497.3553135.703756633.0F6CCC4C@webmail.messagingengine.com>
Joshua Phillips <jphillips@imap.cc> writes:
Show 9 quoted lines
> I've found a case where git pull --rebase discards commits in my branch > if the remote-tracking branch was rewound (and the remote tracking > branch's reflog contains my branch's latest commit). This is due to > git-pull's usage of git merge-base --fork-point. > > On one hand, this behaviour might be correct since the remote repository > essentially removed that commit from master by 'reset --hard'. On the > other hand, I was surprised that git pull --rebase discarded a commit in > my branch.
Yup, that sounds like a bad way to handle the situation. After all, the upstream may have first accepted your first attempt, and then decided that it was premature and rewound it, expecting you to give an improved reroll. But I also agree with you that it may be correct to drop it because the upstream already rejected it.
Since Git cannot tell between these two cases, we should play safer than what the current code does, I would think.