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 switchandgit 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 logandgit diffbetween 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
- Create two branches and make commits.
- Merge a branch into main.
- Create and resolve a conflict.
- Compare branches with
git diff. - 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 branchandgit 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).