LESSON 7

Merging

Learning objective: Combine branches with merge.

Understand

Merging brings a branch's work back into main.

When a feature is ready, switch to main and git merge the feature branch to combine the changes. Sometimes Git needs your help to resolve conflicts when the same lines changed in both branches.

Analogy: Merging is like combining two drafts of a document into one final version.

See It in Action

Merging a feature:

git switch main
git merge feature-nav
How it works: You move to main first, then merge the feature branch so its commits become part of main.

Try It Yourself

  1. Finish work on a feature branch.
  2. Switch back to main.
  3. Merge the feature branch in.

Quick Quiz

What can happen when the same lines changed in both branches?

Challenge

Merge a feature branch into main and confirm the changes are present.

Success condition: Your main branch now contains the feature branch's work.