Skip to content
This repository has been archived by the owner on May 29, 2022. It is now read-only.

How to Rebase a Feature Branch

Bryan Masamitsu Parsons edited this page Sep 25, 2018 · 1 revision

HOWTO Rebase a Feature Branch

Simple Recipe:

  1. Don't do it!
  2. Merge instead.

Detailed Recipe:

  1. The Golden Rule of Rebase: Never rebase after you have shared the branch with others
    • It is far too easy to screw things up if you rebase on a "public" branch, i.e. one visible to others
    • If you have never pushed the feature branch, then it's okay to rebase
    • After you have shared, always do a merge, not a rebase
  2. Update the master branch
    • git checkout master
    • git pull
  3. Checkout the feature branch
    • git checkout feature1
  4. Rebase
    • git rebase master feature1
  5. Push
    • Be careful! The use of "--force" in the following push will over-write the remote tracking branch with the rebased version, so if other people are working on this feature branch, bad things will happen.
    • git push --force origin feature1