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

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.

Previous: Joshua PhillipsNext: Igor Djordjevic
Message 2 of 3 in “Possible bug: git pull --rebase discards local commits”
  1. Joshua PhillipsAug 23, 2016
  2. Junio C HamanoAug 23, 2016
  3. Igor DjordjevicMar 10, 2017

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.