What is Rebasing and why is Rebasing?

Submitted by Rajasekhar on Sat, 11/10/2018 - 13:32
  1. At a Glance - Sometimes we will want to incorporate new changes from the branch we branched from into our feature branch. To do this, we can use the Git rebase command.
    • Check out the feature branch to rebase.
    • Use the Git rebase command with the target branch.
    • Continue to work with new changes incorporated into the feature branch.
  2. What is Rebasing – A method of combining two branches that doesn’t create a merge commit. To do this, it replays the commits from a feature branch on top of the target branch.
  3. Why Rebasing – Avoids creating unnecessary merge commits in the repository’s history. Rebasing can be used to incorporate changes into your branch that were added after you branched.
  4. When not to rebase – Rebasing is a very useful tool, but it can also be very dangerous. Never rebase public branches onto your feature branch, for example, master.