Skip to content

Instantly share code, notes, and snippets.

@abachman
Last active January 26, 2024 17:26
Show Gist options
  • Save abachman/4fdc1d791e653b964c5c61f4e6991c3d to your computer and use it in GitHub Desktop.
Save abachman/4fdc1d791e653b964c5c61f4e6991c3d to your computer and use it in GitHub Desktop.
git rebase --onto

I HAVE:

main     -- A -- B
                  \
staging            C -- D
                         \
feature                   E  

I WANT:

main     -- A -- B
                 |\      
staging          | C -- D
                  \       
feature            E        

COMMAND:

$ git rebase --onto main staging feature

OR IF YOU HAVE feature CHECKED OUT LOCALLY:

$ git rebase --onto main staging 

MNEMONIC DEVICE

GIT, PLEASE REBASE THE BRANCH feature, ONTO main AS THOUGH feature WERE BASED ON staging

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment