Branching, merging and resolving a conflict · seed 1 · A4, ink-friendly. The answer key prints on its own page for grown-ups.
En anglais

Merging work without losing meaning

Computing · Software Engineering · ages 18-19
Name ______________________   Date ____________
  1. Which pair of changes is likely to need manual text resolution during a merge?

    • Both branches replace one line with exactly the same new text.
    • Each branch edits a separate file without renaming or deleting it.
    • Both branches replace one line with incompatible new text.
  2. Q has parent P. R and S each have parent Q. The branch tips are R and S. Which commit is their merge base?

    • Q
    • P
    • R
    • S
  3. Git replays commit X onto Y to create X'. X' has a different parent from X, so X' has a new commit ID.

    Circle one:   True   False

  4. Main changes an error message. Feature adds a check for missing input. Both changes are required. During conflict resolution, what result should you aim for?

    • Keep the changed message while discarding the missing-input check.
    • Keep the changed message and input check, then test both.
    • Keep only the missing-input check.
  5. A merge paused with a conflict in settings.py. You edited it, removed the markers and passed the relevant tests. What completes this ordinary merge?

    • Run git add settings.py, then git commit.
    • Run git commit without git add.
    • Create another branch without staging or committing the file.
  6. Main and feature have diverged. An ordinary merge finishes by creating a merge commit. Which ancestry does that new commit record?

    • One parent at the merge base, with both branch tips removed.
    • Two parents at the original main and feature tips.
    • One parent at a replayed feature tip, replacing both original tips.
  7. If Git reports no text conflicts during a merge, the combined program is guaranteed to meet its behavior requirements.

    Circle one:   True   False

  8. Your private branch needs an updated base for review; nobody uses its commits. Another branch has commits teammates use. Which plan avoids rewriting their history?

    • Rebase both branches without coordination.
    • Merge your private branch but rebase the branch that teammates already use.
    • Rebase your private branch and merge the branch that teammates use.
LightMySky · lightmysky.comW1-mt_l3vFbU7L3E-s1

Answer key

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

Merging work without losing meaning W1-mt_l3vFbU7L3E-s1

  1. Both branches replace one line with incompatible new text. · Incompatible replacements at the same place can prevent Git from combining the text automatically.
  2. Q · Both tips lead back to Q. P is also shared, but Q is the more recent shared ancestor.
  3. True · The parent is part of a commit's identity. Replaying X with a different parent creates a different commit.
  4. Keep the changed message and input check, then test both. · Both changes are required, so the resolved code must preserve both behaviors and be checked.
  5. Run git add settings.py, then git commit. · Stage the resolved file so Git records its resolution, then create the merge commit.
  6. Two parents at the original main and feature tips. · This merge commit records both original branch tips as its parents.
  7. False · Git can combine text automatically even when the changes interact badly at runtime.
  8. Rebase your private branch and merge the branch that teammates use. · Rebase the private work. Merging the shared work preserves the commits and ancestry teammates already use.
Worksheet · LightMySky