git: how to interactive rebase commits found in remote branch B on top of local branch A?

I am basically wanting to interactively rebase 2 changes (shas 1a28dba and be7c442) found in remote-branch-b, on top of local-branch-a so I can push them to remote-branch-a.

I tried this (along with a few other variations); however, the changes I were looking for weren't applied after the rebase; I believe I had local-branch-b checked out when I executed this:

git rebase -i --onto local-branch-a remote-branch-b

The results in the interactive session are weird; not sure what the noop is; however, the shas are correct (i.e. Rebase 10b67a636..10b67a636 onto 8d00e80c2 (1 command)):

# Rebase 10b67a636..10b67a636 onto 8d00e80c2 (1 command)
# Commands:
# p, pick <commit> = use commit
# r, reword <commit> = use commit, but edit the commit message
# e, edit <commit> = use commit, but stop for amending
# s, squash <commit> = use commit, but meld into previous commit
# f, fixup [-C | -c] <commit> = like "squash" but keep only the previous
#                    commit's log message, unless -C is used, in which case
#                    keep only this commit's message; -c is same as -C but
#                    opens the editor
# x, exec <command> = run command (the rest of the line) using shell
# b, break = stop here (continue rebase later with 'git rebase --continue')
# d, drop <commit> = remove commit
# l, label <label> = label current HEAD with a name
# t, reset <label> = reset HEAD to a label
# m, merge [-C <commit> | -c <commit>] <label> [# <oneline>]
# .       create a merge commit using the original merge commit's
# .       message (or the oneline, if no original merge commit was
# .       specified); use -c <commit> to reword the commit message
# These lines can be re-ordered; they are executed from top to bottom.
# If you remove a line here THAT COMMIT WILL BE LOST.
# However, if you remove everything, the rebase will be aborted.

Any help would be appreciated.

1 answer

  • answered 2021-07-27 17:03 eftshift0

    You should run it like this:

    git rebase --onto remote-branch-a remote-branch-b~2 remote-branch-b

    Use -i if you really need to do something interactive with it.

    update: Maybe what you meant to run was:

    git rebase --onto remote-branch-a local-branch-a remote-branch-b

    That should work if local-branch-a is 2 revisions behind remote-branch-b

How many English words
do you know?
Test your English vocabulary size, and measure
how many words do you know
Online Test
Powered by Examplum