git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: put THEIR commits AFTER my commits with a single rebase command

From
Johan Herland <johan@herland.net>
Date
Apr 18, 2013, 06:21 UTC
Message-ID
<CALKQrgeYrsOOR9z+khOkGWhy38LPXwHFo9wf8RrZr3LsM3zTAg@mail.gmail.com>
In-Reply-To
<1928280357.20130418091807@gmail.com>
On Thu, Apr 18, 2013 at 7:18 AM, Ilya Basin <basinilya@gmail.com> wrote:
Show 15 quoted lines
> I asked this on stackoverflow, but no reply.
> http://stackoverflow.com/questions/15971244/git-put-their-commits-after-my-commits-with-a-single-rebase-command
>
> Suppose master and origin/master diverged.
> I'm on master and I want to put the commits from origin/master after my commits and then push --force.
>
>          A---B---C origin/master
>         /
>     D---E---F---G *master
>
> desired result:
>
>          A---B---C origin/master
>         /
>     D---E---F---G---A'---B'---C' *master

Note that if other people are working on top of origin/master, then what you are proposing is quite rude to them, since they must now manually rebase their own work on top of your rebased history. Rewriting public history is generally considered evil.

Show 16 quoted lines
> Variant 1:
>
>     git branch -f tmp
>     git reset --hard origin/master
>     git rebase tmp
>
> 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.
> Variant 2:
>
>     git branch -f tmp origin/master
>     git rebase --onto master master tmp
>     git branch -f master
>     git checkout master
>
> Too many commands. I want to do this with just one command. And I want
> to stay be on branch master in case of rebase conflicts.
git cherry-pick master..origin/master
...Johan

-- Johan Herland, <johan@herland.net> www.herland.net

Previous: Ilya BasinNext: Ilya Basin
Message 2 of 6 in “put THEIR commits AFTER my commits with a single rebase command”
  1. Ilya BasinApr 18, 2013
  2. Johan HerlandApr 18, 2013
  3. Re[2]: put THEIR commits AFTER my commits with a single rebase commandIlya Basin, Apr 18, 2013
  4. Johannes SixtApr 18, 2013
  5. Re[2]: put THEIR commits AFTER my commits with a single rebase commandIlya Basin, Apr 18, 2013
  6. Johannes SixtApr 18, 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.