Re: Possible bug: git pull --rebase discards local commits
From: Junio C Hamano <hidden>
Date: 2016-08-23 19:30:01
Joshua Phillips [off-list ref] writes:
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.