Lesson Completion
Back to course

Module 03: Branching and Merging

Overview

This module teaches how to create branches, switch between them, merge work safely, and handle conflicts.

Learning Objectives

  • Understand what branches are and why they exist
  • Create and switch branches
  • Merge branches safely
  • Resolve merge conflicts
  • Use fast-forward vs merge commits
  • Delete and clean up branches
  • Compare branches and commits

Topics Covered

3.1 What is a Branch?

  • Branch as a pointer to a commit
  • Why branches are lightweight

3.2 Creating Branches

  • git branch
  • Naming conventions

3.3 Switching Branches

  • git switch and git checkout
  • Moving between work streams

3.4 Merging Branches

  • Fast-forward merge
  • Three-way merge

3.5 Merge Conflicts

  • Why conflicts happen
  • Conflict markers

3.6 Resolving Conflicts

  • Edit, stage, commit
  • Conflict resolution flow

3.7 Comparing Branches

  • git log and git diff between branches

3.8 Deleting Branches

  • Local branch cleanup
  • Safe vs forced delete

3.9 Rebase vs Merge (Conceptual)

  • When to choose each
  • Pros and cons

3.10 Branching Best Practices

  • Feature branches
  • Keep branches short-lived

Hands-on Exercises

  1. Create two branches and make commits.
  2. Merge a branch into main.
  3. Create and resolve a conflict.
  4. Compare branches with git diff.
  5. Delete merged branches.

Key Takeaways

  • Branches make parallel work safe and fast.
  • Merges combine histories; conflicts are normal.
  • Clean branch practices keep history readable.

Additional Resources

  • Pro Git: Branching and Merging
  • git help branch and git help merge

Assessment

  • Quiz on branching concepts
  • Practical: create, merge, and resolve conflicts

Next Module

Module 04 will cover working with remotes (clone, fetch, pull, push).