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

Re: Moving commits from one branch to another (improving my git fu!)

From
Bryan Turner <bturner@atlassian.com>
Date
Oct 22, 2013, 06:00 UTC
Message-ID
<CAGyf7-EDtNPhAGm21YmPSZfWmdjhKejhmoWNG3Au5LaorOodCw@mail.gmail.com>
In-Reply-To
<CAC+QLdSjTjftgUBy-1cHbATZnX-UO3PavUaLwErhCaxBa-hPmQ@mail.gmail.com>

A quick glance at your command line and the man page for git rebase suggests the problem was you didn't actually use --onto. I believe the correct command would be:

git rebase --onto dev stable topicA

That should start by determining which commits are one topicA but not stable and then checkout dev and apply those new commits.

Hope this helps, Bryan Turner

On 22 October 2013 16:38, Mandeep Sandhu <mandeepsandhu.chd@gmail.com> wrote:
Show 47 quoted lines
> Hi All,
>
> I'm in a bit of a pickle! :) So I've come to ask for help from the guru's here.
>
> My story is not unique but somehow the various suggested solutions
> don't seem to work in my case.
>
> * I was working on a feature which was supposed to be done off our
> 'dev' branch. But instead I forgot and branched out my topic branch
> from master (or as we call it 'stable').
> * I did 2 commits and finished off my work. Only later realizing that
> it had to be done off 'dev'.
> * Now I want to move my 2 commits (which are the top 2 commits on my
> topic branch) to a new branch which is branched off 'dev'.
>
> $ git branch
> * topicA
> * stable
> * dev
>
> topicA was based on stable. But now I want to base it dev.
>
> So I did what was most suggested, i.e use 'git rebase --onto'.
>
> Here's what I did when I was in topicA:
>
> $ git rebase dev stable topicA
> (this was suggested in the manpage as well).
>
> This started off a massive rebase operation, because the 'dev' branch
> is vastly diverged from stable, and a lot of conflicts started
> appearing.
>
> I'm not sure if I'm doing it right here, so can anyone suggest whether
> this is right or do I need to do it differently?
>
> PS: Please CC me (mandeepsandhu.chd@gmail.com) in your reply as I'm
> not currently subscribed to the list.
>
> Thanks for your time.
>
> Regards,
> -mandeep
> --
> To unsubscribe from this list: send the line "unsubscribe git" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
Previous: Mandeep SandhuNext: Mandeep Sandhu
Message 4 of 7 in “Moving commits from one branch to another (improving my git fu!)”
  1. Mandeep SandhuOct 22, 2013
  2. Peter KreftingOct 22, 2013
  3. Mandeep SandhuOct 22, 2013
  4. Bryan TurnerOct 22, 2013
  5. Mandeep SandhuOct 22, 2013
  6. Noufal IbrahimOct 22, 2013
  7. Mandeep SandhuOct 22, 2013

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.