Skip to content

Instantly share code, notes, and snippets.

@jonesmac
Created April 21, 2020 21:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jonesmac/80bb45656cbcf9b02f15fa9e3e295fc9 to your computer and use it in GitHub Desktop.
Save jonesmac/80bb45656cbcf9b02f15fa9e3e295fc9 to your computer and use it in GitHub Desktop.
When you have a feature branch that is squashed merged and you need to 'catch up' new feature work that depends on the non-squashed history.

Given I have a setup like so

    A---B---C---D  develop
         \
          E---F---G---H---I  feature/123
                           \
                            J---L---M  feature/124

And feature/123 is squash merged (N) into develop leaving feature/124 with extra commits

    A---B---C---D---N  develop
                 \
                  E---F---G---H---I  feature/123
                                     \
                                      J---L---M  feature/124

Assuming you have feature/124 checked out, you can use git rebase --onto develop feature/123 to end up with

    A---B---C---D---N  develop
                     \
                      J---L---M  feature/124

What's actually taking place when you run the command:

  1. set develop (currently at N) (arg 1) as the new base branch for your current branch - feature/124
  • --onto is saying reset feature/124 on to develop's tip
  1. set feature/123 (currently at I) (arg 2) as the starting point for the new commits
  • All changes made by commits in feature/124 but that are not in feature/123 (J, L, and M) are saved to a temporary area.
  1. replay the commits in the temporary area to branch feature/124
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment