Re: Moving commits from one branch to another

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Wed, Jan 23, 2013 at 03:13:19PM +0100, Stefan Schulze wrote:
> > > Is there any way to move/copy commits from one branch to another
> > > without a common base-commit and without a forced push of master?
> >
> > Did you try "git rebase" with "--onto"?  You probably want something
> > like this:
> > 
> >     git rebase --onto svnbranch publishedToSvn master
> 
> I already tried this some days ago, but wasn't sure about the result. The
> resulting history looks exactly what I expected, but all the commits are on
> master after executing this commands and svnbranch only contains the
> original two commits (svn-commit creating the root directory and the
> cherry-picked commit from master)

Ah, I missed that you wanted to update svnbranch.  I don't think there's
a single command that will do that, but this should work:

    git rebase --onto svnbranch publishedToSvn master^0
    git checkout -B svnbranch HEAD

This uses a detached head to avoid modifying the wrong branch and then
updates "svnbranch" to point at that after the rebase.

> Does the current branch matter if I call git-rebase with the
> <branch>-argument?

No it will checkout that branch first.


John
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]