Git & GitHub Mastery: Workflows & CI/CD
Back to Git Fundamentals

Branches & Merging

Create branches, switch between them, merge them back. The mechanics and the two flavors of merge (fast-forward and three-way). FIND_VIDEO: search 'git branching merging tutorial' — recommended channel: Fireship / Atlassian Bitbucket. Aim for 10 min or under.

6 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. Navigating Existing Branches — Developers use `git checkout` to switch between established branches, isolating changes from the main development line.
  2. Creating New Branch — The `-b` flag is used with `checkout` to create a new branch and immediately switch context to it.
  3. Implementing Changes — Changes are added locally to the current branch, preparing them for integration by modifying existing files and creating new ones.
  4. Preparing Target Branch — The developer switches back to the main branch because merging must be performed while on the target branch that will receive the changes.
  5. Executing and Committing Merge — Changes from the source branch are integrated into the target branch, and the resulting merge state is staged and committed to finalize the integration history.
PDF notes

Frequently asked questions

Why do I have to switch back to `master` before merging?

Git merges are directional; the branch you are checked out on is the target that receives the changes from the source branch specified in the command.

What happens if I checkout an older commit hash instead of a branch name?

You enter a detached HEAD state, meaning you are viewing history but any new commits won't belong to a named branch unless you explicitly create one.

Does `git checkout -b` automatically commit the changes?

No, it only creates the pointer and switches context; you must still stage and commit your modifications manually.

How was this lesson?

Your feedback helps us refine explanations and catch bugs.