git rebase?!

https://hackernoon.com/git-merge-vs-rebase-whats-the-diff-76413c117333

The one-line summary: don’t rebase a branch unless you are the only one who uses it. Or you enjoy chaos.

In summary, when looking to incorporate changes from one Git branch into another:

  • Use merge in cases where you want a set of commits to be clearly grouped together in history

  • Use rebase when you want to keep a linear commit history

  • DON'T use rebase on a public /shared branch

Merge

git checkout master
git merge feature

By merging feature into master, master obtains a new commit -- a "merge commit".

Rebase

re-base

Before we continue working on our feature branch, we decide we want to bring in the latest changes from master to keep things fresh.

Rather that merging master's new commits into feature, we opt to rebase our feature branch onto master.

git checkout feature
git rebase master

At a high level, rebasing can be understood as "moving the base of a branch onto a different position". Think of it like a redo--"I meant to start here."

Last updated

Was this helpful?