Do you know to Rebase not Merge?

Last updated by TiagoAraujo about 8 years ago.See history

When you merge a branch you end up with messy merge commits.

Rebasing might take a bit to get your head around, but you get a much cleaner project history.

  • it eliminates the unnecessary merge commits required by git merge
  • rebasing also results in a perfectly linear project history - you can follow the tip of feature all the way to the beginning of the project without any forks.

This makes it easier to navigate your project with commands like git log, git bisect, and gitk.

rebase1
Figure: When merging: a messy merge commit is created any time you need to incorporate upstream changes from the master branch

rebase2
Figure: Git Rebase moves your new commits to the end of the master branch. This ensure that you don't end up with messy merge commits and you have a clean linear project history

Warning: If you don’t follow the Golden Rule of Rebasing, you could end up in a world of pain.

We open source. Powered by GitHub