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
| Section | Time | Required? |
|---|---|---|
| Watch | 10 min | ⚑ Required |
| Understand | 10 min | ⚑ Required |
| Branch commands | 10 min | ⚑ Required |
| Explore | Open | ◎ Optional |
| Reflect | 20 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 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
| Level | You can... | ||
|---|---|---|---|
| 🪨 | Intro Climb | Explain what a branch is and why you would use one | ⚑ Required |
| 🧗 | Core Ascent | Create a branch, make a commit on it, and explain what a pull request does | ⚑ Required |
| 🏔️ | Summit | Describe the full branch → commit → PR → merge workflow without notes | ◎ Optional |
Reflect
Add your answers to the same document as your previous reflections.
- What is main?
- Why create a branch
- 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.