Re: bug: `git pull --rebase` breaks in the presence of pushurls
- From
- Phillip Wood <phillip.wood123@gmail.com>
- Date
- Dec 10, 2025, 14:25 UTC
- Message-ID
- <61f61218-1945-4efe-961a-e6cb4ac8c6a9@gmail.com>
- In-Reply-To
- <xmqqa4zsliim.fsf@gitster.g>
On 08/12/2025 22:24, Junio C Hamano wrote:
Show 29 quoted lines
> Phillip Wood <phillip.wood123@gmail.com> writes: > >> "git push" updates refs/remotes/origin/master when pushing to "mirror". >> >>> 8. Try to fix the problem: >>> >>> git pull --rebase >> >> "git pull" tries to find the fork point between origin/master and master >> which is the tip of master because "git push" just updated origin/master >> to point to the same commit as master. >> >> Unfortunately I'm not sure there is an easy way to fix this. For now I'd >> recommend doing >> >> git fetch && git rebase --no-fork-point >> >> instead of running "git pull --rebase". > > Yeah, it is an integral part of "fetch" to update the > remote-tracking branches, so this is harder to fix. > > It may be possible to stop doing the fork-point computation in the > "git rebase" phase, and instead do it _before_ we run "git fetch", > to figure out what part of our history needs to be transplanted on > top of the upstream, run "git fetch" (to let the tracking branches > updated), and then run "git rebase", telling it exactly what range > should be transplanted onto which commit to update the branch > currently checked out. That would be a much larger change.
"git pull" already runs "git merge-base --fork-point" before it runs "git fetch". The problematic reflog entry comes from a previous push which pushes to a different server due to remote.<remote>.pushurl. Because we've just successfully pushed the local branch the fork point calculation thinks the remote tracking branch matches the local branch and so excludes all the local commits when we rebase but we didn't push it to the same server that we're fetching from. I wonder if we should disable the fork point calculation when there is a pushurl set.
Thanks
Phillip