Lesson 12 / 28

git merge

Combine branches with git merge and tell fast-forward merges from three-way merges.

Merging a branch in

Switch to the branch you want to merge into, then merge the other one in.

git switch main
git merge feature/login

Output:

Updating a1b2c3d..9f8e7d6
Fast-forward
 login.js | 12 ++++++++++++

Fast-forward vs 3-way

If main hasn't moved since the branch split off, Git just slides the pointer forward (fast-forward). If both sides have new commits, Git creates a new merge commit joining both histories (3-way merge).