{"thread":{"id":"32701","subject":"Moving commits from one branch to another","startedAt":"2013-01-23T12:04:03Z","lastAt":"2013-01-23T15:44:00Z","messageCount":5,"participants":["Stefan Schulze","John Keeping","Schulze, Stefan"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"207586","messageId":"000a01cdf961$bcf773d0$36e65b70$@de","threadId":"32701","inReplyTo":null,"subject":"Moving commits from one branch to another","fromName":"Stefan Schulze","fromEmail":"algroth@gmx.de","sentAt":"2013-01-23T12:04:03Z","receivedAt":"2013-01-23T12:04:03Z","isPatch":false,"sender":{"key":"algroth@gmx.de","avatar":null},"body":"Hi,\n\nmy team uses a central git-repo since >1500 commits and now we have to sync\n(only one-way is necessary for now) our repository every three weeks with an\nexternal svn-repo.\nI created the new base-directory (incl. trunk/tags/branches) in svn and\nadded it to my local repo using git svn init && git fetch.\nNow I have two branches in my local repository (master and \"svnbranch\") and\ncherry-picked the very first commit from master to svnbranch (it was\nprobably not necessary), tagged this commit as \"publishedToSvn\". Now I want\nto add all commits publishedToSvn..master onto svnbranch. I didn't managed\nto succeed using git-rebase (probably because of the missing common\ncommits?) and using git grafts / filter-branch modifies my already published\nmaster.\n\nIs there any way to move/copy commits from one branch to another without a\ncommon base-commit and without a forced push of master?\n\nThanks in advance,\n  Stefan Schulze\n"},{"id":"207588","messageId":"20130123121203.GM7498@serenity.lan","threadId":"32701","inReplyTo":"000a01cdf961$bcf773d0$36e65b70$@de","subject":"Re: Moving commits from one branch to another","fromName":"John Keeping","fromEmail":"john@keeping.me.uk","sentAt":"2013-01-23T12:12:03Z","receivedAt":"2013-01-23T12:12:03Z","isPatch":false,"sender":{"key":"john@keeping.me.uk","avatar":"https://avatars.githubusercontent.com/u/1702081?v=4"},"body":"On Wed, Jan 23, 2013 at 01:04:03PM +0100, Stefan Schulze wrote:\n> my team uses a central git-repo since >1500 commits and now we have to sync\n> (only one-way is necessary for now) our repository every three weeks with an\n> external svn-repo.\n> I created the new base-directory (incl. trunk/tags/branches) in svn and\n> added it to my local repo using git svn init && git fetch.\n> Now I have two branches in my local repository (master and \"svnbranch\") and\n> cherry-picked the very first commit from master to svnbranch (it was\n> probably not necessary), tagged this commit as \"publishedToSvn\". Now I want\n> to add all commits publishedToSvn..master onto svnbranch. I didn't managed\n> to succeed using git-rebase (probably because of the missing common\n> commits?) and using git grafts / filter-branch modifies my already published\n> master.\n> \n> Is there any way to move/copy commits from one branch to another without a\n> common base-commit and without a forced push of master?\n\nDid you try \"git rebase\" with \"--onto\"?  You probably want something\nlike this:\n\n    git rebase --onto svnbranch publishedToSvn master\n\n\nJohn\n"},{"id":"207594","messageId":"000b01cdf973$cc685fc0$65391f40$@de","threadId":"32701","inReplyTo":"20130123121203.GM7498@serenity.lan","subject":"AW: Moving commits from one branch to another","fromName":"Stefan Schulze","fromEmail":"algroth@gmx.de","sentAt":"2013-01-23T14:13:19Z","receivedAt":"2013-01-23T14:13:19Z","isPatch":false,"sender":{"key":"algroth@gmx.de","avatar":null},"body":"> > Is there any way to move/copy commits from one branch to another\n> > without a common base-commit and without a forced push of master?\n>\n> Did you try \"git rebase\" with \"--onto\"?  You probably want something\n> like this:\n> \n>     git rebase --onto svnbranch publishedToSvn master\n\nI already tried this some days ago, but wasn't sure about the result. The\nresulting history looks exactly what I expected, but all the commits are on\nmaster after executing this commands and svnbranch only contains the\noriginal two commits (svn-commit creating the root directory and the\ncherry-picked commit from master)\n\nDoes the current branch matter if I call git-rebase with the\n<branch>-argument?\n"},{"id":"207597","messageId":"20130123144941.GO7498@serenity.lan","threadId":"32701","inReplyTo":"000b01cdf973$cc685fc0$65391f40$@de","subject":"Re: Moving commits from one branch to another","fromName":"John Keeping","fromEmail":"john@keeping.me.uk","sentAt":"2013-01-23T14:49:41Z","receivedAt":"2013-01-23T14:49:41Z","isPatch":false,"sender":{"key":"john@keeping.me.uk","avatar":"https://avatars.githubusercontent.com/u/1702081?v=4"},"body":"On Wed, Jan 23, 2013 at 03:13:19PM +0100, Stefan Schulze wrote:\n> > > Is there any way to move/copy commits from one branch to another\n> > > without a common base-commit and without a forced push of master?\n> >\n> > Did you try \"git rebase\" with \"--onto\"?  You probably want something\n> > like this:\n> > \n> >     git rebase --onto svnbranch publishedToSvn master\n> \n> I already tried this some days ago, but wasn't sure about the result. The\n> resulting history looks exactly what I expected, but all the commits are on\n> master after executing this commands and svnbranch only contains the\n> original two commits (svn-commit creating the root directory and the\n> cherry-picked commit from master)\n\nAh, I missed that you wanted to update svnbranch.  I don't think there's\na single command that will do that, but this should work:\n\n    git rebase --onto svnbranch publishedToSvn master^0\n    git checkout -B svnbranch HEAD\n\nThis uses a detached head to avoid modifying the wrong branch and then\nupdates \"svnbranch\" to point at that after the rebase.\n\n> Does the current branch matter if I call git-rebase with the\n> <branch>-argument?\n\nNo it will checkout that branch first.\n\n\nJohn\n"},{"id":"207602","messageId":"1897BAB9F1563C4BBBF69D9E554ECAA50A45C40559@horus","threadId":"32701","inReplyTo":"20130123144941.GO7498@serenity.lan","subject":"AW: Moving commits from one branch to another","fromName":"Schulze, Stefan","fromEmail":"stefan.schulze@ckc.de","sentAt":"2013-01-23T15:44:00Z","receivedAt":"2013-01-23T15:44:00Z","isPatch":false,"sender":{"key":"stefan.schulze@ckc.de","avatar":null},"body":"> git rebase --onto svnbranch publishedToSvn master^0\n> git checkout -B svnbranch HEAD\n\nGreat! This does exactly what I want!\n\nThanks for your support,\n  Stefan Schulze\n\n--------------------------\nckc ag\nSitz:\nAm Alten Bahnhof 13\n38122 Braunschweig\n\nTelefon +49 (0)531 / 80 110 0\nTelefax +49 (0)531 / 80 110 18444\nhttp://www.ckc-group.de\n\nAmtsgericht Braunschweig\nHRB 5405\n\nVorstand:\nH.-G. Christian Krentel\n(Vorsitzender)\nKarsten Kisser\n\nAufsichtsrat:\nDr. Heinz-Werner Weinrich\n(Vorsitzender)\nJens Fokuhl\n(stellv. Vorsitzender)\nProf. Dr. Reinhold Haux\nCäsar Jaworski\nDr. Rita Schulz\nThorsten Sponholz\n--------------------------\n"}]}