← VCE Software Development U4O1

Branches and merging

Creates a branch, a separate line of development that you work on safely and later combine into the main branch with git merge.

Understanding Branches and merging in VCE Software Development U4O1

What it does: git checkout followed by a branch name moves you onto that branch so you can work on it. git branch creates a new branch. git merge combines a branch into the one you are on. A branch lets you add features or fix bugs without affecting the main branch until you are ready to merge. git checkout switches the branch you are working on. Newer Git versions also offer git switch. When both branches edit the same part of a file, Git asks you to choose which changes to keep. Resolve the conflict markers in the file by hand, then stage and commit to complete the merge.

Common mistakes: The command is misspelled. It should be git commit, which saves the changes on the login branch. git new-branch is not a Git command. A branch is created with git branch feature-menu.

Class: _____________________  ·  Name: _____________________  ·  Date: _________

Free printable worksheet with full answer key — or add this module to a class and your students practise it interactively.

This module's key terms are also in a printable crossword (Modules 115–124) and word search (Modules 115–171).

Take this worksheet further — free with Cloodit

Each concept is reinforced from every angle — learned, then applied, then tested.

Learning
Duo
Which command creates a new branch called login-form?
git branch login-formgit merge login-form
Matches
git checkout main git merge main
↓
Merging main into itself does nothing. The name after git merge should be the feature branch whose changes you want to bring into main.
Applying
Meanings
Term
git branch
Meaning
Creates a branch, a separate line of development that you work on safely and later combine into the main branch with git merge.
Practice
git branch login-page
Testing
Gaps
git login-form
Check Answer
Spots
2git checkout login
3git comit -am "Add login"

Cloodit turns curriculum-aligned coding content into journeys students work through one biome at a time.

The 'Sea Dragon' badge — OOP Pioneer, one of Cloodit's 106 collectible badges
Students earn collectable badges

Over 100 of them, across seven natural biomes.

Study Buddy
Students build a real study resource

Turns their work into revision material ready for Flash Cards and Exam study.

Diamond Dash — one of Cloodit's live, competitive Sprint games
Students lock in with Sprints

Live, competitive practice for the start of the lesson or a teacher-led lesson finisher.

A Cloodit certificate of achievement, ready to personalise and print
Custom printable certificates

Honour your top performers, or encourage a student who's trying hard — ready to print in seconds.

Quick Questions

1. Which command creates a new branch called login-form?
A. git merge login-form
B. git branch login-form ✓
git branch creates a new branch. git merge combines a branch into the one you are on.
2. What is the purpose of a branch?
A. A separate line of development you can work on safely ✓
B. A backup copy that can never be changed
A branch lets you add features or fix bugs without affecting the main branch until you are ready to merge.
3. Which command switches you onto the branch login-form?
A. git checkout login-form ✓
B. git branch -m login-form
git checkout switches the branch you are working on. Newer Git versions also offer git switch.
4. You finished a feature on login-form. To combine it into main, which steps are correct?
A. git checkout login-form, then git merge main
B. git checkout main, then git merge login-form ✓
Switch to the branch that will receive the changes (main), then merge the feature branch into it.
5. What is a merge conflict?
A. Two branches changed the same lines, so Git cannot combine them automatically ✓
B. A branch has been deleted from the repository by mistake
When both branches edit the same part of a file, Git asks you to choose which changes to keep.

Match the Pairs

git branch login-page → Creates a new branch called login-page, a separate line of development, without changing the main branch.
git merge login-page → Combines the changes from the login-page branch into the branch you are currently on, such as main.
Switch to a branch so your new commits are added to that line of development instead of main. → git checkout login-page
To combine a finished feature branch into main, first switch to main and then run the merge command. → git checkout main git merge login-page
git checkout main git merge main → Merging main into itself does nothing. The name after git merge should be the feature branch whose changes you want to bring into main.
<<<<<<< HEAD score = 10 ======= score = 20 >>>>>>> login-page → This is a merge conflict. Both branches changed the same line, so Git cannot choose one. The markers must be removed and one version kept before committing.

Key Term

git branch
Creates a branch, a separate line of development that you work on safely and later combine into the main branch with git merge.

Fill in the Blanks

1. git branch login-form
Hint: Type the git subcommand that creates a new branch.
2. git checkout login-form
Hint: Type the git subcommand that switches to another branch.
3. git checkout main git merge login-form
Hint: Type the git subcommand that combines a branch into the current branch.
4. git checkout main git merge login-form
Hint: Type the name of the branch you must switch to before merging, because the changes are merged into it.
5. CONFLICT (content): Merge conflict in app.py
Hint: Type the word for when git cannot combine changes automatically and you must fix the file yourself.

Spot the Error

Question 1
A git branch login
B git checkout login
C git comit -am "Add login"
Line C — The command is misspelled. It should be git commit, which saves the changes on the login branch.
Question 2
A git new-branch feature-menu
B git checkout feature-menu
C git commit -am "Add menu"
Line A — git new-branch is not a Git command. A branch is created with git branch feature-menu.
Question 3
A git checkout main
B git merge dark-mode
C git branch -b dark-mode
Line C — -b is not a valid option for git branch. Use -d to delete a branch once it has been merged into main.
Question 4
A git branch report
B git checkout main
C git add report.py
D git commit -m "Add report"
Line B — This keeps the student on main, so the report work would be committed to main instead of the new branch. It should be git checkout report.
Question 5
A git checkout main
B git merge main
C git branch -d search
Line B — You are already on main, so this does not bring in the search work. The branch to combine must be named: git merge search.

Student with a class code? Join your class →