Git & GitHub Mastery: Workflows & CI/CD
Back to Real-World Git Workflows

Rebase vs Merge

The two ways to integrate changes. When each is better, and the philosophical 'rewrite history vs preserve history' debate. FIND_VIDEO: search 'git rebase vs merge tutorial' — recommended channel: Atlassian / Fireship. Aim for 11 min or under.

10 minutesVideo LessonPDF notes
🎯 Free Guest Mode: You are learning for free. Sign in to save your completion progress and quiz answers.
Loading progress...

Key moments

  1. Three-Way Merge — The three-way merge integrates diverging histories by creating a new commit based on the common ancestor.
  2. Merging onto Feature Branch — Merging is a non-destructive way to keep a feature branch up-to-date with the main branch changes.
  3. Fast-Forward Control — A fast-forward merge moves the pointer forward without a merge commit unless the `--no-fast-forward` flag is used.
  4. Rebase Mechanics — Rebase rewrites history by replaying commits onto a new base, creating a clean, linear history.
  5. Rebase Risks — Rebase fundamentally alters history by creating new commit objects with different hashes, requiring conflict resolution.
  6. The Golden Rule — Never rebase branches that have been shared publicly because it causes divergent histories for collaborators.
PDF notes

Frequently asked questions

What is a fast-forward merge?

It occurs when history is linear and the branch pointer can simply move forward. No merge commit is created, resulting in a perfectly straight history.

Why does rebase change commit hashes?

Rebase discards the original commits and creates new ones when replaying them onto the new base. Since commit hashes are based on content and parent history, the new commits get new hashes.

When should I use `--no-fast-forward`?

Use this flag when you want to explicitly document the integration point of a feature branch, even if Git could perform a fast-forward merge.

What is the 'common ancestor' in a three-way merge?

It is the last commit shared by both branches before they diverged. Git uses this anchor point to calculate the unique changes on each side.

How was this lesson?

Your feedback helps us refine explanations and catch bugs.