{"thread":{"id":"33531","subject":"put THEIR commits AFTER my commits with a single rebase command","startedAt":"2013-04-18T05:18:07Z","lastAt":"2013-04-18T11:03:10Z","messageCount":6,"participants":["Ilya Basin","Johannes Sixt","Johan Herland"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"214677","messageId":"1928280357.20130418091807@gmail.com","threadId":"33531","inReplyTo":null,"subject":"put THEIR commits AFTER my commits with a single rebase command","fromName":"Ilya Basin","fromEmail":"basinilya@gmail.com","sentAt":"2013-04-18T05:18:07Z","receivedAt":"2013-04-18T05:18:07Z","isPatch":false,"sender":{"key":"basinilya@gmail.com","avatar":null},"body":"I asked this on stackoverflow, but no reply.\nhttp://stackoverflow.com/questions/15971244/git-put-their-commits-after-my-commits-with-a-single-rebase-command\n\nSuppose master and origin/master diverged.\nI'm on master and I want to put the commits from origin/master after my commits and then push --force.  \n\n         A---B---C origin/master\n        /\n    D---E---F---G *master\n\ndesired result:\n\n         A---B---C origin/master\n        /\n    D---E---F---G---A'---B'---C' *master\n\n\n\nVariant 1:\n\n    git branch -f tmp\n    git reset --hard origin/master\n    git rebase tmp\n\nThis variant is bad, because 'git reset --hard' checks out some files and 'git rebase' rewrites them again before applying commits. It's a redundant job.  \nVariant 2:\n\n    git branch -f tmp origin/master\n    git rebase --onto master master tmp\n    git branch -f master\n    git checkout master\n\nToo many commands. I want to do this with just one command. And I want\nto stay be on branch master in case of rebase conflicts.\n"},{"id":"214681","messageId":"CALKQrgeYrsOOR9z+khOkGWhy38LPXwHFo9wf8RrZr3LsM3zTAg@mail.gmail.com","threadId":"33531","inReplyTo":"1928280357.20130418091807@gmail.com","subject":"Re: put THEIR commits AFTER my commits with a single rebase command","fromName":"Johan Herland","fromEmail":"johan@herland.net","sentAt":"2013-04-18T06:21:18Z","receivedAt":"2013-04-18T06:21:18Z","isPatch":false,"sender":{"key":"johan@herland.net","avatar":"https://avatars.githubusercontent.com/u/547031?v=4"},"body":"On Thu, Apr 18, 2013 at 7:18 AM, Ilya Basin <basinilya@gmail.com> wrote:\n> I asked this on stackoverflow, but no reply.\n> http://stackoverflow.com/questions/15971244/git-put-their-commits-after-my-commits-with-a-single-rebase-command\n>\n> Suppose master and origin/master diverged.\n> I'm on master and I want to put the commits from origin/master after my commits and then push --force.\n>\n>          A---B---C origin/master\n>         /\n>     D---E---F---G *master\n>\n> desired result:\n>\n>          A---B---C origin/master\n>         /\n>     D---E---F---G---A'---B'---C' *master\n\nNote that if other people are working on top of origin/master, then\nwhat you are proposing is quite rude to them, since they must now\nmanually rebase their own work on top of your rebased history.\nRewriting public history is generally considered evil.\n\n> Variant 1:\n>\n>     git branch -f tmp\n>     git reset --hard origin/master\n>     git rebase tmp\n>\n> This variant is bad, because 'git reset --hard' checks out some files and 'git rebase' rewrites them again before applying commits. It's a redundant job.\n> Variant 2:\n>\n>     git branch -f tmp origin/master\n>     git rebase --onto master master tmp\n>     git branch -f master\n>     git checkout master\n>\n> Too many commands. I want to do this with just one command. And I want\n> to stay be on branch master in case of rebase conflicts.\n\ngit cherry-pick master..origin/master\n\n\n...Johan\n\n--\nJohan Herland, <johan@herland.net>\nwww.herland.net\n"},{"id":"214680","messageId":"516F9329.4060405@viscovery.net","threadId":"33531","inReplyTo":"1928280357.20130418091807@gmail.com","subject":"Re: put THEIR commits AFTER my commits with a single rebase command","fromName":"Johannes Sixt","fromEmail":"j.sixt@viscovery.net","sentAt":"2013-04-18T06:31:05Z","receivedAt":"2013-04-18T06:31:05Z","isPatch":false,"sender":{"key":"j6t@kdbg.org","avatar":"https://avatars.githubusercontent.com/u/14810926?v=4"},"body":"Am 4/18/2013 7:18, schrieb Ilya Basin:\n> desired result:\n> \n>          A---B---C origin/master\n>         /\n>     D---E---F---G---A'---B'---C' *master\n> \n> \n> \n> Variant 1:\n> \n>     git branch -f tmp\n>     git reset --hard origin/master\n>     git rebase tmp\n\nVariant 1a:\n\n   git reset --hard origin/master\n   git rebase @{1}\n\n> \n> This variant is bad, because 'git reset --hard' checks out some files\n> and 'git rebase' rewrites them again before applying commits. It's a\nredundant job.\n>\n> Variant 2:\n> \n>     git branch -f tmp origin/master\n>     git rebase --onto master master tmp\n>     git branch -f master\n>     git checkout master\n> \n> Too many commands. I want to do this with just one command. And I want\n> to stay be on branch master in case of rebase conflicts.\n\nPerhaps this one:\n\n   git merge origin/master\n   git rebase ORIG_HEAD\n\n-- Hannes\n"},{"id":"214683","messageId":"1279652941.20130418105900@gmail.com","threadId":"33531","inReplyTo":"CALKQrgeYrsOOR9z+khOkGWhy38LPXwHFo9wf8RrZr3LsM3zTAg@mail.gmail.com","subject":"Re[2]: put THEIR commits AFTER my commits with a single rebase command","fromName":"Ilya Basin","fromEmail":"basinilya@gmail.com","sentAt":"2013-04-18T06:59:00Z","receivedAt":"2013-04-18T06:59:00Z","isPatch":false,"sender":{"key":"basinilya@gmail.com","avatar":null},"body":"JH> git cherry-pick master..origin/master\n\nThanks Johan.\n"},{"id":"214694","messageId":"1949082828.20130418123321@gmail.com","threadId":"33531","inReplyTo":"516F9329.4060405@viscovery.net","subject":"Re[2]: put THEIR commits AFTER my commits with a single rebase command","fromName":"Ilya Basin","fromEmail":"basinilya@gmail.com","sentAt":"2013-04-18T08:33:21Z","receivedAt":"2013-04-18T08:33:21Z","isPatch":false,"sender":{"key":"basinilya@gmail.com","avatar":null},"body":"\nJS> Perhaps this one:\n\nJS>    git merge origin/master\nJS>    git rebase ORIG_HEAD\n\nJS> -- Hannes\n\nWouldn't I have to resolve conflicts twice?\n\n\nBTW, during the rebase, can I tell git to rewrite a different branch\nupon rebase success or abort?\n\n    git branch -f tmp origin/master\n    git rebase --onto master master tmp\n    if [ $? -ne 0 ]; then\n       # modify some file in .git/ ?\n    else\n        git branch -f master\n        git checkout master\n    fi\n\n\n\n-- \n"},{"id":"214716","messageId":"516FD2EE.4040300@viscovery.net","threadId":"33531","inReplyTo":"1949082828.20130418123321@gmail.com","subject":"Re: put THEIR commits AFTER my commits with a single rebase command","fromName":"Johannes Sixt","fromEmail":"j.sixt@viscovery.net","sentAt":"2013-04-18T11:03:10Z","receivedAt":"2013-04-18T11:03:10Z","isPatch":false,"sender":{"key":"j6t@kdbg.org","avatar":"https://avatars.githubusercontent.com/u/14810926?v=4"},"body":"Am 4/18/2013 10:33, schrieb Ilya Basin:\n> \n> JS> Perhaps this one:\n> \n> JS>    git merge origin/master\n> JS>    git rebase ORIG_HEAD\n> \n> JS> -- Hannes\n> \n> Wouldn't I have to resolve conflicts twice?\n\nYes. But you did run 'git config rerere.enabled true' when you started\nwith git, didn't you? ;-)\n\nAnyway, Johan's idea to use git cherry-pick is much better.\n\n> BTW, during the rebase, can I tell git to rewrite a different branch\n> upon rebase success or abort?\n> \n>     git branch -f tmp origin/master\n>     git rebase --onto master master tmp\n>     if [ $? -ne 0 ]; then\n>        # modify some file in .git/ ?\n\nWhat do you expect here? Failure of git rebase means that it is not\ncomplete, yet. So far, nothing has been rewritten. So what? Perhaps you mean:\n\t# never mind\n\tgit rebase --abort\n\n>     else\n>         git branch -f master\n>         git checkout master\n>     fi\n\n-- Hannes\n"}]}