Practice Version Control in CS Thinking

Use these practice problems to test your method after reviewing the concept explanation and worked examples.

Quick Recap

A system that records changes to files over time so you can recall specific versions, compare changes, and collaborate without overwriting each other's work. Git is the most widely used version control system, using concepts like commits (snapshots), branches (parallel lines of development), and merges (combining changes).

Version control is an unlimited undo button for your entire project β€” plus the ability for multiple people to work on the same files simultaneously.

Showing a random 20 of 50 problems.

Example 1

medium
You want to temporarily set aside uncommitted changes to switch branches, then restore them later. Which Git feature does this?

Example 2

medium
You committed a secret API key 10 commits ago. You ran gitΒ rm\text{git rm} and committed. Is the secret safe now?

Example 3

hard
Three feature branches each made 2 commits from main. They all merge sequentially. Main was at c3c_3; now it has how many MORE commits at minimum (assuming no fast-forward)?

Example 4

easy
What is version control and why is it important? Describe what happens without it.

Example 5

medium
A feature branch has 5 commits. You want a single tidy commit on main. Which workflow achieves this?

Example 6

medium
Two developers both edit the same line of the same file on different branches. What happens when they try to merge? How should this be resolved?

Example 7

challenge
A branch was created from main at commit c3c_3 (the common ancestor). The branch added 3 commits and main added 2 commits, none touching the same files. Using a three-way merge, how many commits are processed to build the merge result, and how many parents does the merge commit have?

Example 8

hard
A merge commit has 2 parents. A fast-forward merge produces how many new commits and how many parents?

Example 9

easy
Which Git command downloads the latest commits from the remote and merges them?

Example 10

hard
Explain how version control supports the maintenance stage of the SDLC. Describe a scenario where the ability to revert to a previous version saves a project.

Example 11

easy
True or false: version control lets multiple people work on the same files at the same time.

Example 12

challenge
Given the commit chain c0β†’c1β†’β‹―β†’cnc_0 \to c_1 \to \cdots \to c_n, a bug was introduced between c0c_0 and cnc_n. Which Git command finds the offending commit in O(log⁑n)O(\log n) steps via binary search?

Example 13

medium
Two engineers edit different lines of the same file in separate branches. They merge sequentially into main. How many conflicts arise?

Example 14

easy
Which Git command uploads your local commits to a remote repository?

Example 15

easy
Which Git command creates a new branch named 'feature'?

Example 16

medium
After an automatic merge fails, Git inserts markers in the file. After the line beginning with '<<<<<<<', whose changes appear first?

Example 17

medium
Order these into the standard collaborative workflow: (1) commit, (2) pull latest, (3) push, (4) make changes. Give the sequence.

Example 18

easy
Two branches edited the SAME line of the same file differently. What does Git report when you merge them?

Example 19

easy
Before starting new work on a shared branch, what should you do first to reduce conflicts?

Example 20

medium
Explain these Git operations and their purpose: commit, branch, merge. How do they support team collaboration?