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
Peter Krefting <peter@softwolves.pp.se>
Date
Oct 22, 2013, 05:52 UTC
Message-ID
<alpine.DEB.2.00.1310220647400.13299@ds9.cixit.se>
In-Reply-To
<CAC+QLdSjTjftgUBy-1cHbATZnX-UO3PavUaLwErhCaxBa-hPmQ@mail.gmail.com>
Mandeep Sandhu:
> Here's what I did when I was in topicA:
>
> $ git rebase dev stable topicA
> (this was suggested in the manpage as well).

I guess you also had an "--onto" in there, as the above would throw a syntax error. As long as the branches are in order, I cannot see how that wouldn't do what you wanted.

However, the easiest way to do it would probably just to run:
  git checkout topicA
  git rebase dev

As long as "dev" already contains all the commits in "stable", that should work fine. If not, then you would need something more complicated.

Another way to do it would be to use cherry-pick on a new branch:
  git checkout -b new_topicA dev
  git cherry-pick stable..topicA
-- 
\\// Peter - http://www.softwolves.pp.se/
Previous: Mandeep SandhuNext: Mandeep Sandhu
Message 2 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.