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

Re: [PATCH] rebase [--onto O] A B: omit needless checkout

From
Johannes Sixt <j.sixt@viscovery.net>
Date
Mar 19, 2008, 12:54 UTC
Message-ID
<47E10D0D.2080702@viscovery.net>
In-Reply-To
<7vk5k3n2ho.fsf_-_@gitster.siamese.dyndns.org>
Junio C Hamano schrieb:
Show 13 quoted lines
> This teaches "git rebase [--onto O] A B" to omit an unnecessary checkout
> of branch B before it goes on.
> 
> "git-rebase" originally was about rebasing the current branch to somewhere
> else, and when the extra parameter to name which branch to rebase was
> added, it defined the semantics to the safest but stupid "first switch to
> the named branch and then operate exactly the same way as if we were
> already on that branch".
> 
> But the first thing the real part of "rebase" does is to reset the work
> tree and the index to the "onto" commit.  Which means the "rebase that
> branch" form switched the work tree to the tip of the branch only to
> immediately switch again to another commit.  This was wasteful.
This works for a frequent use-case of mine:
  $ git rebase master devel

where I am already on branch master, and now want to rebase devel on top of it.

The code seems to take care of a lot of corner cases and less frequent use-cases, including using --onto, which I don't feel able to judge about.

> +# git reset --hard "$onto^0"
Don't forget to remove this line. ;)
-- Hannes
Previous: Junio C HamanoNext: Junio C Hamano
Message 7 of 10 in “optimized checkout+rebase?”
  1. Ralf WildenhuesMar 12, 2008
  2. Johannes SixtMar 13, 2008
  3. Ralf WildenhuesMar 15, 2008
  4. rebase [--onto O] A B: omit needless checkoutJunio C Hamano, Mar 15, 2008
  5. Ralf WildenhuesMar 15, 2008
  6. Junio C HamanoMar 16, 2008
  7. Johannes SixtMar 19, 2008
  8. Junio C HamanoMar 19, 2008
  9. Johannes SixtMar 20, 2008
  10. Junio C HamanoMar 20, 2008

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.