Module 6 · ~40 min
Branches & merging
Goal: Work on features safely without breaking the stable main branch.
Why branches?
main should stay working. Branches let you build features in isolation, then merge when ready.
Practice exercise
- Create a branch:
git switch -c add-about-page - Edit files and commit on the branch.
- Push:
git push -u origin add-about-page - On GitHub: Pull requests → New — base
main, compare your branch. - Review Files changed → Merge pull request.
- Locally:
git switch mainthengit pull origin main
Merge conflicts (brief)
If two branches edit the same lines, resolve conflict markers in the file, then git add and git commit.
| Command | Purpose |
|---|---|
git branch | List local branches |
git switch <name> | Change branch |
git merge <branch> | Merge into current branch |
Checklist
- I created a branch and committed on it
- I opened and merged a pull request
- I updated local
mainwithgit pull