Version control for software projects

Tip: Choose Save as PDF in the print dialog to download. Use A4 paper size.

Version control for software projects

Name:
Date:
Class:

Quick Questions

Shade in the A or B circle for each question.

1. What does a commit do in version control?
A Deletes the older versions of the files to save space
B Saves a snapshot of the changes along with a message and the author
2. Which statement about version control is correct?
A It lets you see who changed what and when
B It only stores the latest copy of each file
3. Why would a developer create a branch?
A To work on a new feature without affecting the main version
B To permanently delete the main version of the project
4. A recent commit introduced a bug that broke the login screen. What is the best use of version control?
A Start the whole project again from scratch
B Restore the previous working version
5. Which commit message is better practice?
A Add password check to login form
B stuff changed

Match the Pairs

Draw a line connecting each item on the left to its match on the right.

Left columnRight column
1git commit -m "Add login form" AWorking on the same branch at the same time risks overwriting each other's changes. Each developer should work on their own branch and merge later.
2git checkout -b new-menu Bgit revert a1b2c3d
3Rolling back by restoring a previous version of the project after a change has broken the software CThe change was not staged with git add and has no message, so the history does not clearly record what was changed or why.
4Tracking who changed what by viewing the history of recorded changes in the project Dgit log
5git commit (no message, and nothing staged with git add) ESaves a snapshot of the staged changes to the project history, with a message describing what changed and who made it
6Two developers both edit main.py directly on the main branch all day FCreates a new branch called new-menu and switches to it, so a developer can work in parallel without affecting the main code

Definitions

version control

Fill in the Blanks

Complete each line of code by filling in the missing parts.

1.
git add main.py git ______ -m "Fix score bug"
2.
git ______ feature-login
3.
git checkout main git _____ feature-login
4.
git ___ --oneline
5.
git ______ a1b2c3d

Spot the Error

Shade in the letter of the line that contains an error.

Question 1
A git init
B git adds main.py
C git commit -m "Add login"
Question 2
A git branch login
B git switch login
C git add main.py
D git commit "Add form"
E git switch main
F git merge login
Question 3
A git switch main
B git merge main
C git log --oneline
Question 4
A git log --oneline main.py
B # a1b2c3d Before the bug
C git commit a1b2c3d main.py
D git commit -m "Restore main.py"
Question 5
A git start
B git add .
C git commit -m "Start"

Answer Key

Version control for software projects
Section A: Quick Questions
Q1
B — Saves a snapshot of the changes along with a message and the author
Q2
A — It lets you see who changed what and when
Q3
A — To work on a new feature without affecting the main version
Q4
B — Restore the previous working version
Q5
A — Add password check to login form
Section B: Match the Pairs
Q1
git commit -m "Add login form" → Saves a snapshot of the staged changes to the project history, with a message describing what changed and who made it
Q2
git checkout -b new-menu → Creates a new branch called new-menu and switches to it, so a developer can work in parallel without affecting the main code
Q3
Rolling back by restoring a previous version of the project after a change has broken the software → git revert a1b2c3d
Q4
Tracking who changed what by viewing the history of recorded changes in the project → git log
Q5
git commit (no message, and nothing staged with git add) → The change was not staged with git add and has no message, so the history does not clearly record what was changed or why.
Q6
Two developers both edit main.py directly on the main branch all day → Working on the same branch at the same time risks overwriting each other's changes. Each developer should work on their own branch and merge later.
Section C: Definitions
Q1
version control — A system that records every change to project files, so developers can see who changed what, work in parallel on branches, and roll back to an earlier version.
Section D: Fill in the Blanks
Q1
git add main.py git commit -m "Fix score bug"
Q2
git branch feature-login
Q3
git checkout main git merge feature-login
Q4
git log --oneline
Q5
git revert a1b2c3d
Section E: Spot the Error
Q1
B — The command to stage a file for the next commit is git add, not git adds. It should be git add main.py.
Q2
D — A commit message needs the -m flag. Without it, git treats the text as a file name. It should be git commit -m "Add form".
Q3
B — While on main, you merge the branch you want to bring in. That branch is login, so the line should be git merge login. Merging main into itself does nothing.
Q4
C — git commit saves new changes. It does not restore an old version. To bring back main.py from an earlier commit, use git checkout a1b2c3d main.py.
Q5
A — git start is not a command. A new version-controlled repository is created with git init.