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

Re: How to do a reverse rebase?

From
Shawn O. Pearce <spearce@spearce.org>
Date
Aug 20, 2007, 05:58 UTC
Message-ID
<20070820055809.GZ27913@spearce.org>
In-Reply-To
<20070820053237.9349.qmail@science.horizon.com>
linux@horizon.com wrote:
> I don't want to rebase HEAD on *that*, but rather rebase *that*
> on top of the current HEAD.
...
> Currently, when I remember, I'll use git-cherry-pick and manually
> rename branches.
> 
> Is there an easier way?

I don't think so. To do the merge of those files we need a working directory to operate in; that working directory is the one you have. It sounds like what you want is this:

	old=`git symbolic-ref HEAD` &&
	git checkout HEAD^0 &&
	git cherry-pick debug_hack &&
	git branch -f debug_hack HEAD &&
	git checkout $old

What's really needed is to avoid switching to the branch, as you mentioned. Instead switch to the --onto (implied or given by user). That way you can avoid updating a lot of files in the working directory for no (compelling) reason. Looking at the part of git-rebase.sh that is affected by this (l.284-322) this is probably not that difficult to improve. Just a little bit of work to keep track of everything.

Of course `git-rebase -i` is a completely different implementation, so now you are also talking about l.409-480 of that. Ick.

> Or should I just learn StGit?

Probably. It handles patch stacks easier than core Git. Or so I'm told. I find `git rebase -i` good enough for my needs, but it going first to the debug_hack branch, then to the onto does sort of suck.

-- 
Shawn.
Previous: linux@horizon.comNext: Junio C Hamano
Message 2 of 5 in “How to do a reverse rebase?”
  1. linux@horizon.comAug 20, 2007
  2. Shawn O. PearceAug 20, 2007
  3. Junio C HamanoAug 20, 2007
  4. linux@horizon.comAug 20, 2007
  5. Johannes SixtAug 20, 2007

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.