{"thread":{"id":"8859","subject":"How to rebase after upstream was merged?","startedAt":"2007-07-04T12:24:46Z","lastAt":"2007-07-04T13:45:14Z","messageCount":3,"participants":["Johannes Sixt","Johannes Schindelin"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"46478","messageId":"468B918E.FBCADCB9@eudaptics.com","threadId":"8859","inReplyTo":null,"subject":"How to rebase after upstream was merged?","fromName":"Johannes Sixt","fromEmail":"j.sixt@eudaptics.com","sentAt":"2007-07-04T12:24:46Z","receivedAt":"2007-07-04T12:24:46Z","isPatch":false,"sender":{"key":"j6t@kdbg.org","avatar":"https://avatars.githubusercontent.com/u/14810926?v=4"},"body":"I have this history:\n\no--o--o--o--o   <- origin\n    \\        \\\n     x--x--x--M--x--x  <- master (HEAD)\n\nAt this point I would like to rebase to straighten the history, but it\nwon't let me:\n\n    $ git rebase origin\n    Current branch master is up to date.\n\nHowever, if there were additional commits on origin, it would work as\nexpected, i.e. all the 'x', but not 'M',  would be moved on top of\norigin. The reason is that rebase checks whether the merge base of\norigin and HEAD is origin, and exits early if it is.\n\nI would like to extend the check to also check for linear history. How\ncan I do this most efficiently? My first try is along these lines:\n\n  test $(git rev-list origin..HEAD | wc -l) = \\\n       $(git rev-list --no-merges origin..HEAD | wc -l)\n\nIs there a better approach?\n\n-- Hannes\n"},{"id":"46483","messageId":"Pine.LNX.4.64.0707041426570.4071@racer.site","threadId":"8859","inReplyTo":"468B918E.FBCADCB9@eudaptics.com","subject":"Re: How to rebase after upstream was merged?","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2007-07-04T13:30:54Z","receivedAt":"2007-07-04T13:30:54Z","isPatch":false,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"Hi,\n\nOn Wed, 4 Jul 2007, Johannes Sixt wrote:\n\n> I have this history:\n> \n> o--o--o--o--o   <- origin\n>     \\        \\\n>      x--x--x--M--x--x  <- master (HEAD)\n> \n> At this point I would like to rebase to straighten the history, but it\n> won't let me:\n> \n>     $ git rebase origin\n>     Current branch master is up to date.\n\nI'd do something like\n\n$ git checkout -b tmp HEAD~3\n$ git rebase origin\n$ git checkout master\n$ git rebase --onto tmp HEAD~2\n$ git branch -d tmp\n\n> I would like to extend the check to also check for linear history. How\n> can I do this most efficiently? My first try is along these lines:\n> \n>   test $(git rev-list origin..HEAD | wc -l) = \\\n>        $(git rev-list --no-merges origin..HEAD | wc -l)\n> \n> Is there a better approach?\n\nI usually to\n\n\ttest -z \"$(git rev-list --parents origin..HEAD | grep \" .* \")\"\n\nHth,\nDscho\n"},{"id":"46486","messageId":"468BA46A.C66E85CA@eudaptics.com","threadId":"8859","inReplyTo":"Pine.LNX.4.64.0707041426570.4071@racer.site","subject":"Re: How to rebase after upstream was merged?","fromName":"Johannes Sixt","fromEmail":"j.sixt@eudaptics.com","sentAt":"2007-07-04T13:45:14Z","receivedAt":"2007-07-04T13:45:14Z","isPatch":false,"sender":{"key":"j6t@kdbg.org","avatar":"https://avatars.githubusercontent.com/u/14810926?v=4"},"body":"Johannes Schindelin wrote:\n> [...how to check for linear history...]\n> I usually to\n> \n>         test -z \"$(git rev-list --parents origin..HEAD | grep \" .* \")\"\n\nAh, that's much better.\n\nThanks,\n-- Hannes\n"}]}