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

Re: Git rebase no longer defaults to upstream after force push

From
CGCem Gündoğdu <cscallsign@gmail.com>
Date
Apr 18, 2023, 15:54 UTC
Message-ID
<CAGrwipO7odTbuKgwDmU+3hY0pEeTdjxx-_9=oufUdBzyQ_eRvQ@mail.gmail.com>
In-Reply-To
<CA+JQ7M_KuDXBaVTzVwLTx+R4-6-3TOuUOpcchkS26iiosc85Hg@mail.gmail.com>
Hi Erik,
From documentation:
> If <upstream> is not specified, [...] and the --fork-point option is assumed.
The --fork-point option does this:
> Use reflog to find a better common ancestor between <upstream> and <branch> when calculating which commits have been introduced by <branch>.

Since the parent of a is still in the reflog of origin/a, it is not being rebased (the rationale being that the commit *was* in origin/a at some point). If you want to disable this behavior, add --no-fork-point option:

git rebase -ir --no-fork-point
Since this is the documented behavior, it probably is not a bug.

Best, Cem

On Tue, Apr 18, 2023 at 11:34 AM Erik Cervin Edin <erik@cervined.in> wrote:
Show 72 quoted lines
>
> Thank you for filling out a Git bug report!
> Please answer the following questions to help us understand your issue.
>
> What did you do before the bug happened? (Steps to reproduce your issue)
>
>   git init --bare foo.git && git clone foo.git/ foo && cd foo
>   touch bar && git add bar && git commit -m init
>   git push -u
>   git switch -c a
>   seq 1 3 > bar && git add bar && git commit -m 1
>   git push
>   seq 11 13 > bar && git add bar && git commit -m 2
>   git rebase -ir # Works like git rebase -ir @{upstream}
>   git push --force origin main:a
>   git rebase -ir # No longer works like git rebase -ir @{upstream}
>
> What did you expect to happen? (Expected behavior)
>
> After force pushing, I still expected the rebase to work like git
> rebase -ir @{upstream}.
>
> What happened instead? (Actual behavior)
>
> The rebase defaults to a commit other than that of the tip of the
> upstream branch.
>
> What's different between what you expected and what actually happened?
>
> Instead of behaving like git rebase @{upstream}, the rebase seems to
> default to rebasing on-top of the old upstream.
>
> git rebase -ir result in a todo like this:
>
> l onto
>
> t onto
> p f1cfbff 2023-04-18    2
>
> Compared to git rebase -ir @{upstream} which results in a todo like this:
>
> l onto
>
> t onto
> p 01e3c92 2023-04-18    1
> p f1cfbff 2023-04-18    2
>
> Anything else you want to add:
>
> Please review the rest of the bug report below.
> You can delete any lines you don't wish to share.
>
>
> [System Info]
> git version:
> git version 2.40.0
> cpu: x86_64
> no commit associated with this build
> sizeof-long: 8
> sizeof-size_t: 8
> shell-path: /bin/sh
> uname: Linux 5.15.90.1-microsoft-standard-WSL2 #1 SMP Fri Jan 27
> 02:56:13 UTC 2023 x86_64
> compiler info: gnuc: 11.3
> libc info: glibc: 2.35
> $SHELL (typically, interactive shell): /bin/bash
>
>
> [Enabled Hooks]
>
> --
> Erik Cervin-Edin
Previous: Phillip WoodNext: Erik Cervin Edin
Message 3 of 6 in “Git rebase no longer defaults to upstream after force push”
  1. Erik Cervin EdinApr 18, 2023
  2. Phillip WoodApr 18, 2023
  3. Cem GündoğduApr 18, 2023
  4. Erik Cervin EdinApr 19, 2023
  5. Sergey OrganovApr 19, 2023
  6. Felipe ContrerasApr 19, 2023

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.