Merge vs Rebase
Both join two branches. A merge keeps both lines and ties them with a new commit; a rebase moves your commits into one line.
Merge
Joining work from one branch into another. Both sets of changes end up in one place.
A merge joins the work from one branch into another. Git compares the two lines of commits and combines the changes. If only one side moved on, Git just moves the branch forward, which is called a fast-forward. If both sides changed, Git makes a new merge commit that ties them together. If both changed the same lines, you get a merge conflict to sort out by hand.
Rebase
Your commits move to start from a newer point. The past reads as one line.
A rebase moves your branch's commits so they start from a newer point. Git takes each of your commits and replays it on top of the other branch. The result is a straight line of history with no merge commit. Each moved commit gets a new code, because its starting point changed. That is why you should not rebase commits that others have already pulled.
In one line
- Merge
- Joining work from one branch into another. Both sets of changes end up in one place.
- Rebase
- Your commits move to start from a newer point. The past reads as one line.