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

Re: is "git rebase ... [branch]" equivalent to first "git checkout [branch]"?

From
Junio C Hamano <gitster@pobox.com>
Date
Mar 4, 2019, 22:54 UTC
Message-ID
<xmqq4l8iw8rv.fsf@gitster-ct.c.googlers.com>
In-Reply-To
<alpine.LFD.2.21.1903041536460.12447@localhost.localdomain>
"Robert P. J. Day" <rpjday@crashcourse.ca> writes:
Show 6 quoted lines
>   i *think* i know the answer to this based on man page and reading
> the code, but i just want to verify that i'm not missing any subtlety.
> ...
>   "If <branch> is specified, git rebase will perform an automatic git
> checkout <branch> before doing anything else. Otherwise it remains on
> the current branch."
Yes, but with a caveat ;-)

At least, the original scripted version of "git rebase" both designed and implemented the final extra "rebase this one, not the current branch" argument as a pure short-hand for lazy people (like me, who wanted to have such a feature and made it so) to be exact equivalent to "checkout before doing anything else". Which means that HEAD@{} reflog would record such an event as "checkout that switched to the branch", and it would have affected the computation needed if you said "git checkout @{-1}" after the rebase finished.

I do not offhand know if the current verison of "git rebase" that was reimplemented in C changed the behaviour, though.

Previous: Robert P. J. Day
Message 2 of 2 in “is "git rebase ... [branch]" equivalent to first "git checkout [branch]"?”
  1. Robert P. J. DayMar 4, 2019
  2. Junio C HamanoMar 4, 2019

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.