Version Control as a Graph of Commits · seed 1 · A4, ink-friendly. The answer key prints on its own page for grown-ups.

History as a graph of snapshots

Computing · Software Engineering · ages 18-19
Name ______________________   Date ____________
  1. In Git's commit graph, what is a branch?

    • A saved copy of every file in the working folder
    • A movable label pointing to a commit
    • A parent link stored inside every newly made commit
  2. Which description fits a Git commit?

    • A snapshot record with links to zero or more parents
    • A moving branch name that stores the current file edits
    • A second working folder containing each branch's files
  3. main points to commit C. Creating feature at C adds a branch label but no new commit.

    Circle one:   True   False

  4. feature points to C. You check out C using its commit ID. What happens to HEAD?

    • It points directly to C and is detached
    • It points to feature and stays attached
    • It deletes feature and points directly to C
  5. Start with only root commit A, main at A and HEAD pointing to main. Make ordinary commit B, create feature at B, switch to feature, then make ordinary commit C. Which record gives all commit-to-parent arrows and the final pointers?

    • Arrows: A to B, B to C; main: B; feature: C; HEAD: feature
    • Arrows: B to A, C to B; main: C; feature: C; HEAD: feature
    • Arrows: B to A, C to B; main: B; feature: C; HEAD: feature
  6. main stays at C. With HEAD detached at C, you make D and then E. No branch leads to D or E. You switch to main. What is the risk?

    • They are deleted immediately when HEAD returns to the main branch
    • They may be harder to find without a branch leading to them
    • They are merged into main automatically when HEAD returns there
  7. A merge commit with two parents creates a directed cycle in Git's commit graph.

    Circle one:   True   False

  8. HEAD is detached at H. H has parent G, and G has parent F. You want to return to main while keeping this history easy to find. What should you do before switching?

    • Create a branch at F before switching
    • Delete commits G and H before switching
    • Create a branch at H before switching
LightMySky · lightmysky.comW1-mt_oKsDRKirMy-s1

Answer key

For grown-ups. Fold this page away before handing over the rest.

History as a graph of snapshots W1-mt_oKsDRKirMy-s1

  1. A movable label pointing to a commit · A branch is a label pointing to a commit. Moving that label does not change the parent links already stored in commits.
  2. A snapshot record with links to zero or more parents · A commit records a snapshot and its parent links. A root has no parents, an ordinary commit has one, and a merge can have several.
  3. True · Both labels point to the existing commit C. Creating feature does not create another snapshot.
  4. It points directly to C and is detached · Using C's commit ID makes HEAD point directly to C. feature still points to C, but HEAD is detached from the branch name.
  5. Arrows: B to A, C to B; main: B; feature: C; HEAD: feature · B was made on main at A, so B points to parent A and main moves to B. C was made on feature at B, so C points to parent B and feature moves to C. main stays at B; HEAD points to feature. Root A has no parents.
  6. They may be harder to find without a branch leading to them · Switching moves HEAD away without adding a branch for D and E. They are not immediately deleted or merged. A local reflog may help find them for a time.
  7. False · Two parent links do not create a directed cycle. They lead into existing history, and following parent links cannot return to the new merge commit.
  8. Create a branch at H before switching · A branch at H reaches H, G and F. A branch at F cannot reach the later commits by following parent links.
Worksheet · LightMySky