Do you know The Golden Rule of Rebasing?
  v4.0 Posted at 16/02/2016 9:57 AM by Adam Stephensen

​Rebasing is great for ensuring a clean project history... but it can be dangerous in inexperienced hands.

The golden rule of git rebase is to never use it on public branches. (ie. never rebase master).

You should never rebase master onto a feature branch. This would move all of the commits in master onto the tip of  the feature branch (not the other way around). 

Since rebasing results in brand new commits, Git will think that your master branch’s history has diverged from everybody else’s. If you were to Push this to the server... expect lots of pain to fix it up!

Figure: Bad Example: Rebasing master onto a feature branch can cause project history to become confused.    
Figure: To get it wrong in Visual Studio you would need to change the current branch to master and then choose rebase. While this is possible, the VS team have done a good job making it hard to do the wrong thing
Figure: Good Example - Rebase your Feature branch onto Master

Related rules

    Do you feel this rule needs an update?

    If you want to be notified when this rule is updated, please enter your email address:


    Note: Social Media login for Yotpo is not working in IE or Safari, please use Chrome. We are waiting for Yotpo to fix it.