git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Phillip Wood <phillip.wood123@gmail.com>
To: Han Jiang <jhcarl0814@gmail.com>, git@vger.kernel.org
Subject: Re: `git rebase (--no-fork-point) --onto=<newbase> [<upstream> [<branch>]]` leaves HEAD detached and *HEAD not moved when <branch> is exactly `HEAD`
Date: Sun, 1 Sep 2024 16:26:27 +0100	[thread overview]
Message-ID: <61a4fcc1-1dd8-48a4-a1d4-0201232c9b26@gmail.com> (raw)
In-Reply-To: <CANrWfmSY1F4UB2QSjN8XKY7Kwx6FL8SOrz_OadZ4u8XYDpZfBg@mail.gmail.com>

On 01/09/2024 12:02, Han Jiang wrote:
> What did you do before the bug happened? (Steps to reproduce your issue)

> git -C './client/repo' -c 'core.editor=cat' rebase
> --onto=HEAD@{upstream} --interactive "$(git -C './client/repo'
> merge-base --fork-point HEAD@{upstream} HEAD)" HEAD

"git rebase <upstream> <branch>" is designed to switch to a different 
branch before rebasing it. If you do not want to switch branches you 
should use "git rebase <upstream>". "<branch>" is expected to be a 
branch name, not a symbolic ref to the branch like "HEAD".

> Replacing `HEAD` with branch name (`"$(git -C './client/repo' branch
> --show-current)"`) works around the problem.

This is working as expected.

"git checkout HEAD" is a no-op so "git rebase <upstream> HEAD" is 
behaving differently to "git checkout HEAD && git rebase <upstream>". We 
could look at changing that but it would be a breaking change for anyone 
relying on the current behavior to detach HEAD before rebasing.

Best Wishes

Phillip

  reply	other threads:[~2024-09-01 15:26 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-09-01 11:02 `git rebase (--no-fork-point) --onto=<newbase> [<upstream> [<branch>]]` leaves HEAD detached and *HEAD not moved when <branch> is exactly `HEAD` Han Jiang
2024-09-01 15:26 ` Phillip Wood [this message]
2024-09-01 15:42   ` Junio C Hamano
2024-09-01 22:05     ` Han Jiang
2024-09-02  9:04     ` Phillip Wood
2024-09-03 15:38       ` Junio C Hamano

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=61a4fcc1-1dd8-48a4-a1d4-0201232c9b26@gmail.com \
    --to=phillip.wood123@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=jhcarl0814@gmail.com \
    --cc=phillip.wood@dunelm.org.uk \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).