Git Rebase: Change base branch

The following is a paraphrasing of the man page for git-rebase[1].

Suppose you have a feature branch feature/example-part1 forked from master and start working on another branch feature/example-part2 based on feature/example-part1, e.g.

               o---o---o---o---o  master
                    \
                     o---o---o---o---o  feature/example-part1
                                      \
                                       o---o---o  feature/example-part2

Now, suppose feature/example-part1 is merged into master, and you want to update feature/example-part2 to have forked from master, i.e.

               o---o---o---o---o  master
                   |            \
                   |             o'--o'--o'  feature/example-part2
                    \
                     o---o---o---o---o  feature/example-part1

You can achieve this on feature/example-part2 with git rebase --onto master feature/example-part1 feature/example-part2

TLDR

You did feature/example-part1master. What about feature/example-part2? You do git rebase --onto master feature/example-part1 feature/example-part2. Do not run twice.

References


  1. "git-rebase(1)." https://www.kernel.org/pub/software/scm/git/docs/git-rebase.html. Accessed 14 Jun. 2017. ↩︎