Branch, Pull, Merge

The Big Idea

Branches let you work on something new without touching your working code. When it is ready, you merge it back. Pull requests are how teams review each other's work before merging. This is how all professional development teams work.


Your Roadmap

SectionTimeRequired?
Watch10 min⚑ Required
Understand10 min⚑ Required
Branch commands10 min⚑ Required
ExploreOpen◎ Optional
Reflect20 min⚑ Required

Watch

Git Branch, Merge and Pull (11 min)


Understand

What is a branch?

Your main branch holds your working, tested code. When you want to try something new — a new feature, an experiment, a fix — you create a branch. A branch is a copy of your code at that point in time. Changes you make on a branch do not affect main until you deliberately merge them.

What is a pull request?

A pull request (PR) is a way of saying: "I've finished this change — can you review it before we merge it?" In a team, at least one other person reviews your PR and merges it once they are happy with the changes. It is how teams avoid accidentally breaking each other's work.

Why does this matter?

  • You can experiment without risking your working code
  • Teams can review changes before they go live
  • You can work in parallel on different features without conflict
Show the branch → pull request → merge flowchartBranch, pull request, and merge workflow flowchart

Branch commands

Create a branch and switch to it:

git checkout -b branch-name

Switch to an existing branch:

git checkout branch-name

List your local branches:

git branch

List all branches including remote:

git branch -a

Explore

Work through these resources. You will use what you learn in the next challenge.


How to know you've nailed it

LevelYou can...
🪨Intro ClimbExplain what a branch is and why you would use one⚑ Required
🧗Core AscentCreate a branch, make a commit on it, and explain what a pull request does⚑ Required
🏔️SummitDescribe the full branch → commit → PR → merge workflow without notes◎ Optional

Reflect

Add your answers to the same document as your previous reflections.

  1. What is main?
  2. Why create a branch
  3. What commands do you use to interact with branches? How do you create them and switch them?

The Big Idea (revisited)

main holds your working code. Branches let you experiment safely. Pull requests let teams review changes before they merge. You will use this workflow every day at Dev Academy and beyond.