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

Re: Created branch in wrong place... how to fix?

From
TGTim Guirgies <lt.infiltrator@gmail.com>
Date
Jun 1, 2011, 12:52 UTC
Message-ID
<20110601125217.GB25353@Imperial-SSD-Overlord>
In-Reply-To
<BANLkTingMK3Zv6NZdFAiLXZzJpSZYZmjQA@mail.gmail.com>
On Wed, Jun 01, 2011 at 01:47:12PM +0100, Howard Miller wrote:
Show 10 quoted lines
> Hi,
> I created a branch in a project and did a series of commits. I now
> discover that I really wanted to make all those changes against a
> completely different branch of the same project. There shouldn't be
> any issues as the branch introduces entirely new files (no changes to
> existing code).
> I'm struggling to see a way to do this without loosing the history.
> Some Google'ing suggests 'rebase --onto' but I'm struggling to see how
> this works or if it is appropriate. Any pointers much appreciated :)
> Thanks.

"git rebase" is indeed what you want to do. Simply put, it takes all your commits and rebases them somewhere else; i.e., makes them sit on top of a different commit. See "git help rebase" for a more detailed explanation.

Of course, if you've already pushed and people have pulled from you, you'll have problems; see the "recovering from upstream rebase" section in "git help rebase".

You'll also want to do "git rebase -i". The "-i" option ensures that you can review what commits will be rebased, and even rearange, leave out, or edit commits.

Good luck.
-- 
() ascii ribbon campaign - against html e-mail
/\ www.asciiribbon.org   - against proprietary attachments
Previous: Howard MillerNext: Jakub Narebski
Message 2 of 4 in “Created branch in wrong place... how to fix?”
  1. Howard MillerJun 1, 2011
  2. Tim GuirgiesJun 1, 2011
  3. Jakub NarebskiJun 1, 2011
  4. Jakub NarebskiJun 2, 2011

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.