When a learner can reproduce a familiar example but a small variation causes confusion, the problem is usually an incomplete model rather than a lack of effort. The fastest useful response is to expose the hidden state and test one boundary at a time.
Git merge-base finds best common ancestor commits in the history graph. A common ancestor is better than another when the latter is an ancestor of the former, and more than one best base can exist. This graph operation underlies three-way comparisons, ancestry checks and several branch workflows, but it does not tell a story about developer intent, create a merge or guarantee that the most recent-looking date is the right base. Mastery means drawing parent edges, handling multiple or missing results, distinguishing ordinary ancestry from reflog-assisted fork-point recovery, and treating exit status and repository completeness as evidence. This guide begins with that mechanism, then develops it through worked traces, deliberate mistakes, explained practice and transfer decisions.
The aim is independent reasoning. A learner should be able to predict behaviour, locate the earliest wrong assumption, use a safe diagnostic procedure and defend a design choice in a new project.
Punggol families can use the guide in short sessions around homework, CCAs and rest. The activities are proposed learning exercises, not claims about a physical branch, timetable, class size, fee, school relationship or guaranteed result.
Use disposable data and repositories, preserve backups, and check version-sensitive details against the official source. Current documentation settles a technical contract; observation and explanation turn that contract into usable knowledge.
Find your next learning step
Choose the route that matches the present difficulty. Use the complete index for a systematic course.
Build the model
Chapters 1-4 . Begin here, then continue after the learner can predict, verify and explain.
Use the core tools
Chapters 5-8 . Begin here, then continue after the learner can predict, verify and explain.
Handle boundaries
Chapters 9-12 . Begin here, then continue after the learner can predict, verify and explain.
Debug and verify
Chapters 13-16 . Begin here, then continue after the learner can predict, verify and explain.
Transfer with judgment
Chapters 17-20 . Begin here, then continue after the learner can predict, verify and explain.
Open the full chapter index . Jump to capstone practice . Use the How Studying Works hub . Read the official documentation
Complete chapter index
Chapters 1-4 . Build the model
Chapters 5-8 . Use the core tools
Chapters 9-12 . Handle boundaries
Chapters 13-16 . Debug and verify
git merge-base works on commit parent relationships and returns a best common ancestor, not the nearest timestamp, matching message or directory snapshot. Treat that sentence as a testable model. A secure learner can point to the relevant input, name the operation, describe the resulting state and identify one observation that would prove the model incomplete.
The high-value mistake in this chapter is looking at dates or branch names and guessing where histories split. It matters because the output may look reasonable while the ownership, ordering, identity or safety rule is wrong. Draw commits as nodes with arrows to parents, mark ancestors of both tips and remove any common ancestor dominated by a better one.
For the A merge base is a graph result chapter on Git merge-base, use a two-column trace during a short Punggol home session. On the left, write the predicted state for this exact mechanism before the tool runs. On the right, record the observation that bears on looking at dates or branch names and guessing where histories split. Explain the earliest difference with one causal sentence, then repeat only the smallest changed case.
Core worked example
git merge-base main topicExplained result. The command prints the object name of a best common ancestor visible in the repository’s commit graph. Check the boundary as well as the happy path: ask what happens with an empty input, a duplicate or tied value, an unsupported type, a missing path, a NULL, or a second reference to the same object. Only the relevant boundary should be kept; the list is a prompt for judgment, not a demand to force every case into every example.
Four purposeful transfer cases
Case 1: school coding project. Predict the rule using main, report and experiment branches with ordinary divergence. State the input grain or object graph, the chapter boundary and the intended output before choosing syntax. Change only one variable, so a wrong prediction has a single plausible cause.
Reasoned route. Begin with “git merge-base works on commit parent relationships and returns a best common ancestor, not the nearest timestamp, matching message or directory snapshot.” Apply this procedure: Draw commits as nodes with arrows to parents, mark ancestors of both tips and remove any common ancestor dominated by a better one. The expected mechanism is: The command prints the object name of a best common ancestor visible in the repository’s commit graph. For the school coding project, add one near-miss that exposes looking at dates or branch names and guessing where histories split. The answer is complete only when it says why the near-miss fails and how the corrected model transfers to a different project without relying on the original variable names.
Case 2: CCA website. Contrast the rule using a feature branch rebased after the remote-tracking branch moved. State the input grain or object graph, the chapter boundary and the intended output before choosing syntax. Change only one variable, so a wrong prediction has a single plausible cause.
Reasoned route. Begin with “git merge-base works on commit parent relationships and returns a best common ancestor, not the nearest timestamp, matching message or directory snapshot.” Apply this procedure: Draw commits as nodes with arrows to parents, mark ancestors of both tips and remove any common ancestor dominated by a better one. The expected mechanism is: The command prints the object name of a best common ancestor visible in the repository’s commit graph. For the CCA website, add one near-miss that exposes looking at dates or branch names and guessing where histories split. The answer is complete only when it says why the near-miss fails and how the corrected model transfers to a different project without relying on the original variable names.
Case 3: group assignment. Stress-test the rule using parallel merges that produce a criss-cross ancestry pattern. State the input grain or object graph, the chapter boundary and the intended output before choosing syntax. Change only one variable, so a wrong prediction has a single plausible cause.
Reasoned route. Begin with “git merge-base works on commit parent relationships and returns a best common ancestor, not the nearest timestamp, matching message or directory snapshot.” Apply this procedure: Draw commits as nodes with arrows to parents, mark ancestors of both tips and remove any common ancestor dominated by a better one. The expected mechanism is: The command prints the object name of a best common ancestor visible in the repository’s commit graph. For the group assignment, add one near-miss that exposes looking at dates or branch names and guessing where histories split. The answer is complete only when it says why the near-miss fails and how the corrected model transfers to a different project without relying on the original variable names.
Case 4: documentation repo. Explain the rule using release, translation and correction branches compared before integration. State the input grain or object graph, the chapter boundary and the intended output before choosing syntax. Change only one variable, so a wrong prediction has a single plausible cause.
Reasoned route. Begin with “git merge-base works on commit parent relationships and returns a best common ancestor, not the nearest timestamp, matching message or directory snapshot.” Apply this procedure: Draw commits as nodes with arrows to parents, mark ancestors of both tips and remove any common ancestor dominated by a better one. The expected mechanism is: The command prints the object name of a best common ancestor visible in the repository’s commit graph. For the documentation repo, add one near-miss that exposes looking at dates or branch names and guessing where histories split. The answer is complete only when it says why the near-miss fails and how the corrected model transfers to a different project without relying on the original variable names.
Diagnostic route
- Model check: ask the learner to draw or list the exact rows, fields, references, paths or states involved.
- Boundary check: create the smallest input that triggers looking at dates or branch names and guessing where histories split.
- Evidence check: separate a printed value from identity, ordering, ownership, type or repository state.
- Repair check: use the reversible procedure “Draw commits as nodes with arrows to parents, mark ancestors of both tips and remove any common ancestor dominated by a better one.” and record the first changed observation.
- Transfer check: repeat the rule in a second context and identify what remains invariant.
A parent does not need to know the final Git merge-base syntax. For this chapter, useful prompts are: “What did you expect from A merge base is a graph result?”, “Which state changed first?”, “What evidence tests that prediction?”, and “Can the case exposing looking at dates or branch names and guessing where histories split be made smaller?” The learner, not the parent, should supply the technical explanation.
Practice with an explained answer
Question. Build a tiny revision repository with shallow clone whose missing parents change what ancestry is visible. Include one ordinary case, one boundary and one deliberate failure caused by looking at dates or branch names and guessing where histories split. Predict each result before using a tool, then report the first point where observation differs from prediction.
Answer guide. A strong response starts with the rule: git merge-base works on commit parent relationships and returns a best common ancestor, not the nearest timestamp, matching message or directory snapshot. It shows a trace, not only a final value. The ordinary case should demonstrate “The command prints the object name of a best common ancestor visible in the repository’s commit graph.” The boundary must exercise the same mechanism at an edge, and the deliberate failure must be repaired with: Draw commits as nodes with arrows to parents, mark ancestors of both tips and remove any common ancestor dominated by a better one. Other data choices are valid when the evidence supports the same causal chain.
Decision and transfer
For A merge base is a graph result, separate the documented Git merge-base mechanism from the project policy. State exactly what the technical contract guarantees, then state the project choice about validation, ordering, ownership, performance or recovery. Test whether the same distinction survives one transfer case, and keep stateful experiments disposable and backed up.
Previous chapter . Contents . Next chapter
A commit is common to A and B when following zero or more parent edges from each tip can reach it. Treat that sentence as a testable model. A secure learner can point to the relevant input, name the operation, describe the resulting state and identify one observation that would prove the model incomplete.
The high-value mistake in this chapter is treating equal files or identical patches as proof two commits share ancestry. It matters because the output may look reasonable while the ownership, ordering, identity or safety rule is wrong. Use rev-list or log graph to trace parent reachability independently of file contents.
For the Common ancestor means reachable from both tips chapter on Git merge-base, use a two-column trace during a short Punggol home session. On the left, write the predicted state for this exact mechanism before the tool runs. On the right, record the observation that bears on treating equal files or identical patches as proof two commits share ancestry. Explain the earliest difference with one causal sentence, then repeat only the smallest changed case.
Core worked example
git rev-list --ancestry-path $(git merge-base main topic)..topicExplained result. The range can inspect commits on an ancestry path after the computed base; content similarity alone never creates a parent edge. Check the boundary as well as the happy path: ask what happens with an empty input, a duplicate or tied value, an unsupported type, a missing path, a NULL, or a second reference to the same object. Only the relevant boundary should be kept; the list is a prompt for judgment, not a demand to force every case into every example.
Four purposeful transfer cases
Case 1: group assignment. Contrast the rule using parallel merges that produce a criss-cross ancestry pattern. State the input grain or object graph, the chapter boundary and the intended output before choosing syntax. Change only one variable, so a wrong prediction has a single plausible cause.
Reasoned route. Begin with “A commit is common to A and B when following zero or more parent edges from each tip can reach it.” Apply this procedure: Use rev-list or log graph to trace parent reachability independently of file contents. The expected mechanism is: The range can inspect commits on an ancestry path after the computed base; content similarity alone never creates a parent edge. For the group assignment, add one near-miss that exposes treating equal files or identical patches as proof two commits share ancestry. The answer is complete only when it says why the near-miss fails and how the corrected model transfers to a different project without relying on the original variable names.
Case 2: documentation repo. Stress-test the rule using release, translation and correction branches compared before integration. State the input grain or object graph, the chapter boundary and the intended output before choosing syntax. Change only one variable, so a wrong prediction has a single plausible cause.
Reasoned route. Begin with “A commit is common to A and B when following zero or more parent edges from each tip can reach it.” Apply this procedure: Use rev-list or log graph to trace parent reachability independently of file contents. The expected mechanism is: The range can inspect commits on an ancestry path after the computed base; content similarity alone never creates a parent edge. For the documentation repo, add one near-miss that exposes treating equal files or identical patches as proof two commits share ancestry. The answer is complete only when it says why the near-miss fails and how the corrected model transfers to a different project without relying on the original variable names.
Case 3: robotics project. Explain the rule using several topic tips reduced to independent work lines. State the input grain or object graph, the chapter boundary and the intended output before choosing syntax. Change only one variable, so a wrong prediction has a single plausible cause.
Reasoned route. Begin with “A commit is common to A and B when following zero or more parent edges from each tip can reach it.” Apply this procedure: Use rev-list or log graph to trace parent reachability independently of file contents. The expected mechanism is: The range can inspect commits on an ancestry path after the computed base; content similarity alone never creates a parent edge. For the robotics project, add one near-miss that exposes treating equal files or identical patches as proof two commits share ancestry. The answer is complete only when it says why the near-miss fails and how the corrected model transfers to a different project without relying on the original variable names.
Case 4: revision repository. Transfer the rule using shallow clone whose missing parents change what ancestry is visible. State the input grain or object graph, the chapter boundary and the intended output before choosing syntax. Change only one variable, so a wrong prediction has a single plausible cause.
Reasoned route. Begin with “A commit is common to A and B when following zero or more parent edges from each tip can reach it.” Apply this procedure: Use rev-list or log graph to trace parent reachability independently of file contents. The expected mechanism is: The range can inspect commits on an ancestry path after the computed base; content similarity alone never creates a parent edge. For the revision repository, add one near-miss that exposes treating equal files or identical patches as proof two commits share ancestry. The answer is complete only when it says why the near-miss fails and how the corrected model transfers to a different project without relying on the original variable names.
Diagnostic route
- Model check: ask the learner to draw or list the exact rows, fields, references, paths or states involved.
- Boundary check: create the smallest input that triggers treating equal files or identical patches as proof two commits share ancestry.
- Evidence check: separate a printed value from identity, ordering, ownership, type or repository state.
- Repair check: use the reversible procedure “Use rev-list or log graph to trace parent reachability independently of file contents.” and record the first changed observation.
- Transfer check: repeat the rule in a second context and identify what remains invariant.
A parent does not need to know the final Git merge-base syntax. For this chapter, useful prompts are: “What did you expect from Common ancestor means reachable from both tips?”, “Which state changed first?”, “What evidence tests that prediction?”, and “Can the case exposing treating equal files or identical patches as proof two commits share ancestry be made smaller?” The learner, not the parent, should supply the technical explanation.
Practice with an explained answer
Question. Build a tiny test laboratory with ordinary, ancestor, unrelated, criss-cross, reflog and expired-reflog histories. Include one ordinary case, one boundary and one deliberate failure caused by treating equal files or identical patches as proof two commits share ancestry. Predict each result before using a tool, then report the first point where observation differs from prediction.
Answer guide. A strong response starts with the rule: A commit is common to A and B when following zero or more parent edges from each tip can reach it. It shows a trace, not only a final value. The ordinary case should demonstrate “The range can inspect commits on an ancestry path after the computed base; content similarity alone never creates a parent edge.” The boundary must exercise the same mechanism at an edge, and the deliberate failure must be repaired with: Use rev-list or log graph to trace parent reachability independently of file contents. Other data choices are valid when the evidence supports the same causal chain.
Decision and transfer
For Common ancestor means reachable from both tips, separate the documented Git merge-base mechanism from the project policy. State exactly what the technical contract guarantees, then state the project choice about validation, ordering, ownership, performance or recovery. Test whether the same distinction survives one transfer case, and keep stateful experiments disposable and backed up.
Previous chapter . Contents . Next chapter
A common ancestor is better than another when the older candidate is an ancestor of the newer candidate; a best base is undominated among common ancestors. Treat that sentence as a testable model. A secure learner can point to the relevant input, name the operation, describe the resulting state and identify one observation that would prove the model incomplete.
The high-value mistake in this chapter is choosing the oldest common root because it is shared by everything. It matters because the output may look reasonable while the ownership, ordering, identity or safety rule is wrong. List all common candidates in a drawn graph and cross out each candidate that is ancestor of another common candidate.
For the Best means no better common ancestor exists chapter on Git merge-base, use a two-column trace during a short Punggol home session. On the left, write the predicted state for this exact mechanism before the tool runs. On the right, record the observation that bears on choosing the oldest common root because it is shared by everything. Explain the earliest difference with one causal sentence, then repeat only the smallest changed case.
Core worked example
base=$(git merge-base main topic)
git show -s --format='%H %P' "$base"Explained result. Inspecting the selected commit and its parents connects the hash to the graph rule rather than to a date-based guess. Check the boundary as well as the happy path: ask what happens with an empty input, a duplicate or tied value, an unsupported type, a missing path, a NULL, or a second reference to the same object. Only the relevant boundary should be kept; the list is a prompt for judgment, not a demand to force every case into every example.
Four purposeful transfer cases
Case 1: robotics project. Stress-test the rule using several topic tips reduced to independent work lines. State the input grain or object graph, the chapter boundary and the intended output before choosing syntax. Change only one variable, so a wrong prediction has a single plausible cause.
Reasoned route. Begin with “A common ancestor is better than another when the older candidate is an ancestor of the newer candidate; a best base is undominated among common ancestors.” Apply this procedure: List all common candidates in a drawn graph and cross out each candidate that is ancestor of another common candidate. The expected mechanism is: Inspecting the selected commit and its parents connects the hash to the graph rule rather than to a date-based guess. For the robotics project, add one near-miss that exposes choosing the oldest common root because it is shared by everything. The answer is complete only when it says why the near-miss fails and how the corrected model transfers to a different project without relying on the original variable names.
Case 2: revision repository. Explain the rule using shallow clone whose missing parents change what ancestry is visible. State the input grain or object graph, the chapter boundary and the intended output before choosing syntax. Change only one variable, so a wrong prediction has a single plausible cause.
Reasoned route. Begin with “A common ancestor is better than another when the older candidate is an ancestor of the newer candidate; a best base is undominated among common ancestors.” Apply this procedure: List all common candidates in a drawn graph and cross out each candidate that is ancestor of another common candidate. The expected mechanism is: Inspecting the selected commit and its parents connects the hash to the graph rule rather than to a date-based guess. For the revision repository, add one near-miss that exposes choosing the oldest common root because it is shared by everything. The answer is complete only when it says why the near-miss fails and how the corrected model transfers to a different project without relying on the original variable names.
Case 3: test laboratory. Transfer the rule using ordinary, ancestor, unrelated, criss-cross, reflog and expired-reflog histories. State the input grain or object graph, the chapter boundary and the intended output before choosing syntax. Change only one variable, so a wrong prediction has a single plausible cause.
Reasoned route. Begin with “A common ancestor is better than another when the older candidate is an ancestor of the newer candidate; a best base is undominated among common ancestors.” Apply this procedure: List all common candidates in a drawn graph and cross out each candidate that is ancestor of another common candidate. The expected mechanism is: Inspecting the selected commit and its parents connects the hash to the graph rule rather than to a date-based guess. For the test laboratory, add one near-miss that exposes choosing the oldest common root because it is shared by everything. The answer is complete only when it says why the near-miss fails and how the corrected model transfers to a different project without relying on the original variable names.
Case 4: design review. Predict the rule using merge-base compared with fork-point, three-dot diff and merge-tree inputs. State the input grain or object graph, the chapter boundary and the intended output before choosing syntax. Change only one variable, so a wrong prediction has a single plausible cause.
Reasoned route. Begin with “A common ancestor is better than another when the older candidate is an ancestor of the newer candidate; a best base is undominated among common ancestors.” Apply this procedure: List all common candidates in a drawn graph and cross out each candidate that is ancestor of another common candidate. The expected mechanism is: Inspecting the selected commit and its parents connects the hash to the graph rule rather than to a date-based guess. For the design review, add one near-miss that exposes choosing the oldest common root because it is shared by everything. The answer is complete only when it says why the near-miss fails and how the corrected model transfers to a different project without relying on the original variable names.
Diagnostic route
- Model check: ask the learner to draw or list the exact rows, fields, references, paths or states involved.
- Boundary check: create the smallest input that triggers choosing the oldest common root because it is shared by everything.
- Evidence check: separate a printed value from identity, ordering, ownership, type or repository state.
- Repair check: use the reversible procedure “List all common candidates in a drawn graph and cross out each candidate that is ancestor of another common candidate.” and record the first changed observation.
- Transfer check: repeat the rule in a second context and identify what remains invariant.
A parent does not need to know the final Git merge-base syntax. For this chapter, useful prompts are: “What did you expect from Best means no better common ancestor exists?”, “Which state changed first?”, “What evidence tests that prediction?”, and “Can the case exposing choosing the oldest common root because it is shared by everything be made smaller?” The learner, not the parent, should supply the technical explanation.
Practice with an explained answer
Question. Build a tiny design review with merge-base compared with fork-point, three-dot diff and merge-tree inputs. Include one ordinary case, one boundary and one deliberate failure caused by choosing the oldest common root because it is shared by everything. Predict each result before using a tool, then report the first point where observation differs from prediction.
Answer guide. A strong response starts with the rule: A common ancestor is better than another when the older candidate is an ancestor of the newer candidate; a best base is undominated among common ancestors. It shows a trace, not only a final value. The ordinary case should demonstrate “Inspecting the selected commit and its parents connects the hash to the graph rule rather than to a date-based guess.” The boundary must exercise the same mechanism at an edge, and the deliberate failure must be repaired with: List all common candidates in a drawn graph and cross out each candidate that is ancestor of another common candidate. Other data choices are valid when the evidence supports the same causal chain.
Decision and transfer
For Best means no better common ancestor exists, separate the documented Git merge-base mechanism from the project policy. State exactly what the technical contract guarantees, then state the project choice about validation, ordering, ownership, performance or recovery. Test whether the same distinction survives one transfer case, and keep stateful experiments disposable and backed up.
Previous chapter . Contents . Next chapter
If A is an ancestor of B, the best common ancestor of A and B is A itself; no separate fork commit is required. Treat that sentence as a testable model. A secure learner can point to the relevant input, name the operation, describe the resulting state and identify one observation that would prove the model incomplete.
The high-value mistake in this chapter is expecting merge-base always to name a commit strictly before both arguments. It matters because the output may look reasonable while the ownership, ordering, identity or safety rule is wrong. Create a linear three-commit history and query the first and third commits.
For the An ancestor tip can be its own merge base chapter on Git merge-base, use a two-column trace during a short Punggol home session. On the left, write the predicted state for this exact mechanism before the tool runs. On the right, record the observation that bears on expecting merge-base always to name a commit strictly before both arguments. Explain the earliest difference with one causal sentence, then repeat only the smallest changed case.
Core worked example
git merge-base HEAD~2 HEADExplained result. The output is HEAD~2 because a commit is reachable from itself and no later commit is an ancestor of the earlier tip. Check the boundary as well as the happy path: ask what happens with an empty input, a duplicate or tied value, an unsupported type, a missing path, a NULL, or a second reference to the same object. Only the relevant boundary should be kept; the list is a prompt for judgment, not a demand to force every case into every example.
Four purposeful transfer cases
Case 1: test laboratory. Explain the rule using ordinary, ancestor, unrelated, criss-cross, reflog and expired-reflog histories. State the input grain or object graph, the chapter boundary and the intended output before choosing syntax. Change only one variable, so a wrong prediction has a single plausible cause.
Reasoned route. Begin with “If A is an ancestor of B, the best common ancestor of A and B is A itself; no separate fork commit is required.” Apply this procedure: Create a linear three-commit history and query the first and third commits. The expected mechanism is: The output is HEAD~2 because a commit is reachable from itself and no later commit is an ancestor of the earlier tip. For the test laboratory, add one near-miss that exposes expecting merge-base always to name a commit strictly before both arguments. The answer is complete only when it says why the near-miss fails and how the corrected model transfers to a different project without relying on the original variable names.
Case 2: design review. Transfer the rule using merge-base compared with fork-point, three-dot diff and merge-tree inputs. State the input grain or object graph, the chapter boundary and the intended output before choosing syntax. Change only one variable, so a wrong prediction has a single plausible cause.
Reasoned route. Begin with “If A is an ancestor of B, the best common ancestor of A and B is A itself; no separate fork commit is required.” Apply this procedure: Create a linear three-commit history and query the first and third commits. The expected mechanism is: The output is HEAD~2 because a commit is reachable from itself and no later commit is an ancestor of the earlier tip. For the design review, add one near-miss that exposes expecting merge-base always to name a commit strictly before both arguments. The answer is complete only when it says why the near-miss fails and how the corrected model transfers to a different project without relying on the original variable names.
Case 3: school coding project. Predict the rule using main, report and experiment branches with ordinary divergence. State the input grain or object graph, the chapter boundary and the intended output before choosing syntax. Change only one variable, so a wrong prediction has a single plausible cause.
Reasoned route. Begin with “If A is an ancestor of B, the best common ancestor of A and B is A itself; no separate fork commit is required.” Apply this procedure: Create a linear three-commit history and query the first and third commits. The expected mechanism is: The output is HEAD~2 because a commit is reachable from itself and no later commit is an ancestor of the earlier tip. For the school coding project, add one near-miss that exposes expecting merge-base always to name a commit strictly before both arguments. The answer is complete only when it says why the near-miss fails and how the corrected model transfers to a different project without relying on the original variable names.
Case 4: CCA website. Contrast the rule using a feature branch rebased after the remote-tracking branch moved. State the input grain or object graph, the chapter boundary and the intended output before choosing syntax. Change only one variable, so a wrong prediction has a single plausible cause.
Reasoned route. Begin with “If A is an ancestor of B, the best common ancestor of A and B is A itself; no separate fork commit is required.” Apply this procedure: Create a linear three-commit history and query the first and third commits. The expected mechanism is: The output is HEAD~2 because a commit is reachable from itself and no later commit is an ancestor of the earlier tip. For the CCA website, add one near-miss that exposes expecting merge-base always to name a commit strictly before both arguments. The answer is complete only when it says why the near-miss fails and how the corrected model transfers to a different project without relying on the original variable names.
Diagnostic route
- Model check: ask the learner to draw or list the exact rows, fields, references, paths or states involved.
- Boundary check: create the smallest input that triggers expecting merge-base always to name a commit strictly before both arguments.
- Evidence check: separate a printed value from identity, ordering, ownership, type or repository state.
- Repair check: use the reversible procedure “Create a linear three-commit history and query the first and third commits.” and record the first changed observation.
- Transfer check: repeat the rule in a second context and identify what remains invariant.
A parent does not need to know the final Git merge-base syntax. For this chapter, useful prompts are: “What did you expect from An ancestor tip can be its own merge base?”, “Which state changed first?”, “What evidence tests that prediction?”, and “Can the case exposing expecting merge-base always to name a commit strictly before both arguments be made smaller?” The learner, not the parent, should supply the technical explanation.
Practice with an explained answer
Question. Build a tiny school coding project with main, report and experiment branches with ordinary divergence. Include one ordinary case, one boundary and one deliberate failure caused by expecting merge-base always to name a commit strictly before both arguments. Predict each result before using a tool, then report the first point where observation differs from prediction.
Answer guide. A strong response starts with the rule: If A is an ancestor of B, the best common ancestor of A and B is A itself; no separate fork commit is required. It shows a trace, not only a final value. The ordinary case should demonstrate “The output is HEAD~2 because a commit is reachable from itself and no later commit is an ancestor of the earlier tip.” The boundary must exercise the same mechanism at an edge, and the deliberate failure must be repaired with: Create a linear three-commit history and query the first and third commits. Other data choices are valid when the evidence supports the same causal chain.
Decision and transfer
For An ancestor tip can be its own merge base, separate the documented Git merge-base mechanism from the project policy. State exactly what the technical contract guarantees, then state the project choice about validation, ordering, ownership, performance or recovery. Test whether the same distinction survives one transfer case, and keep stateful experiments disposable and backed up.
Previous chapter . Contents . Next chapter
In an ordinary fork where main and topic each add commits after one shared parent, that shared parent is the unique best common ancestor. Treat that sentence as a testable model. A secure learner can point to the relevant input, name the operation, describe the resulting state and identify one observation that would prove the model incomplete.
The high-value mistake in this chapter is calling the base the last commit created before the branch command without checking later merges. It matters because the output may look reasonable while the ownership, ordering, identity or safety rule is wrong. Construct the smallest diverged graph, label parent edges and verify the hash from both histories.
For the Diverged branches return their latest shared ancestry chapter on Git merge-base, use a two-column trace during a short Punggol home session. On the left, write the predicted state for this exact mechanism before the tool runs. On the right, record the observation that bears on calling the base the last commit created before the branch command without checking later merges. Explain the earliest difference with one causal sentence, then repeat only the smallest changed case.
Core worked example
git log --graph --oneline --decorate --all
git merge-base --all main topicExplained result. The graph and –all output should agree on the undominated shared commit, making hidden merges visible before interpretation. Check the boundary as well as the happy path: ask what happens with an empty input, a duplicate or tied value, an unsupported type, a missing path, a NULL, or a second reference to the same object. Only the relevant boundary should be kept; the list is a prompt for judgment, not a demand to force every case into every example.
Four purposeful transfer cases
Case 1: school coding project. Transfer the rule using main, report and experiment branches with ordinary divergence. State the input grain or object graph, the chapter boundary and the intended output before choosing syntax. Change only one variable, so a wrong prediction has a single plausible cause.
Reasoned route. Begin with “In an ordinary fork where main and topic each add commits after one shared parent, that shared parent is the unique best common ancestor.” Apply this procedure: Construct the smallest diverged graph, label parent edges and verify the hash from both histories. The expected mechanism is: The graph and –all output should agree on the undominated shared commit, making hidden merges visible before interpretation. For the school coding project, add one near-miss that exposes calling the base the last commit created before the branch command without checking later merges. The answer is complete only when it says why the near-miss fails and how the corrected model transfers to a different project without relying on the original variable names.
Case 2: CCA website. Predict the rule using a feature branch rebased after the remote-tracking branch moved. State the input grain or object graph, the chapter boundary and the intended output before choosing syntax. Change only one variable, so a wrong prediction has a single plausible cause.
Reasoned route. Begin with “In an ordinary fork where main and topic each add commits after one shared parent, that shared parent is the unique best common ancestor.” Apply this procedure: Construct the smallest diverged graph, label parent edges and verify the hash from both histories. The expected mechanism is: The graph and –all output should agree on the undominated shared commit, making hidden merges visible before interpretation. For the CCA website, add one near-miss that exposes calling the base the last commit created before the branch command without checking later merges. The answer is complete only when it says why the near-miss fails and how the corrected model transfers to a different project without relying on the original variable names.
Case 3: group assignment. Contrast the rule using parallel merges that produce a criss-cross ancestry pattern. State the input grain or object graph, the chapter boundary and the intended output before choosing syntax. Change only one variable, so a wrong prediction has a single plausible cause.
Reasoned route. Begin with “In an ordinary fork where main and topic each add commits after one shared parent, that shared parent is the unique best common ancestor.” Apply this procedure: Construct the smallest diverged graph, label parent edges and verify the hash from both histories. The expected mechanism is: The graph and –all output should agree on the undominated shared commit, making hidden merges visible before interpretation. For the group assignment, add one near-miss that exposes calling the base the last commit created before the branch command without checking later merges. The answer is complete only when it says why the near-miss fails and how the corrected model transfers to a different project without relying on the original variable names.
Case 4: documentation repo. Stress-test the rule using release, translation and correction branches compared before integration. State the input grain or object graph, the chapter boundary and the intended output before choosing syntax. Change only one variable, so a wrong prediction has a single plausible cause.
Reasoned route. Begin with “In an ordinary fork where main and topic each add commits after one shared parent, that shared parent is the unique best common ancestor.” Apply this procedure: Construct the smallest diverged graph, label parent edges and verify the hash from both histories. The expected mechanism is: The graph and –all output should agree on the undominated shared commit, making hidden merges visible before interpretation. For the documentation repo, add one near-miss that exposes calling the base the last commit created before the branch command without checking later merges. The answer is complete only when it says why the near-miss fails and how the corrected model transfers to a different project without relying on the original variable names.
Diagnostic route
- Model check: ask the learner to draw or list the exact rows, fields, references, paths or states involved.
- Boundary check: create the smallest input that triggers calling the base the last commit created before the branch command without checking later merges.
- Evidence check: separate a printed value from identity, ordering, ownership, type or repository state.
- Repair check: use the reversible procedure “Construct the smallest diverged graph, label parent edges and verify the hash from both histories.” and record the first changed observation.
- Transfer check: repeat the rule in a second context and identify what remains invariant.
A parent does not need to know the final Git merge-base syntax. For this chapter, useful prompts are: “What did you expect from Diverged branches return their latest shared ancestry?”, “Which state changed first?”, “What evidence tests that prediction?”, and “Can the case exposing calling the base the last commit created before the branch command without checking later merges be made smaller?” The learner, not the parent, should supply the technical explanation.
Practice with an explained answer
Question. Build a tiny CCA website with a feature branch rebased after the remote-tracking branch moved. Include one ordinary case, one boundary and one deliberate failure caused by calling the base the last commit created before the branch command without checking later merges. Predict each result before using a tool, then report the first point where observation differs from prediction.
Answer guide. A strong response starts with the rule: In an ordinary fork where main and topic each add commits after one shared parent, that shared parent is the unique best common ancestor. It shows a trace, not only a final value. The ordinary case should demonstrate “The graph and –all output should agree on the undominated shared commit, making hidden merges visible before interpretation.” The boundary must exercise the same mechanism at an edge, and the deliberate failure must be repaired with: Construct the smallest diverged graph, label parent edges and verify the hash from both histories. Other data choices are valid when the evidence supports the same causal chain.
Decision and transfer
For Diverged branches return their latest shared ancestry, separate the documented Git merge-base mechanism from the project policy. State exactly what the technical contract guarantees, then state the project choice about validation, ordering, ownership, performance or recovery. Test whether the same distinction survives one transfer case, and keep stateful experiments disposable and backed up.
Previous chapter . Contents . Next chapter
CHAPTER 6 OF 20 . Use the core tools
6. Criss-cross histories can have multiple best bases
With criss-cross merging, two common ancestors can be incomparable, so neither is better and both are valid merge bases. Treat that sentence as a testable model. A secure learner can point to the relevant input, name the operation, describe the resulting state and identify one observation that would prove the model incomplete.
The high-value mistake in this chapter is writing a script that silently accepts one arbitrary base when semantics require every best base. It matters because the output may look reasonable while the ownership, ordering, identity or safety rule is wrong. Use –all, count output lines and build an explicit policy for zero, one or many bases.
For the Criss-cross histories can have multiple best bases chapter on Git merge-base, use a two-column trace during a short Punggol home session. On the left, write the predicted state for this exact mechanism before the tool runs. On the right, record the observation that bears on writing a script that silently accepts one arbitrary base when semantics require every best base. Explain the earliest difference with one causal sentence, then repeat only the smallest changed case.
Core worked example
mapfile -t bases < <(git merge-base --all left right)
printf '%s
' "${#bases[@]}"Explained result. A count greater than one is a legitimate graph result, not corruption; downstream code must not pretend the base is uniquely defined. Check the boundary as well as the happy path: ask what happens with an empty input, a duplicate or tied value, an unsupported type, a missing path, a NULL, or a second reference to the same object. Only the relevant boundary should be kept; the list is a prompt for judgment, not a demand to force every case into every example.
Four purposeful transfer cases
Case 1: group assignment. Predict the rule using parallel merges that produce a criss-cross ancestry pattern. State the input grain or object graph, the chapter boundary and the intended output before choosing syntax. Change only one variable, so a wrong prediction has a single plausible cause.
Reasoned route. Begin with “With criss-cross merging, two common ancestors can be incomparable, so neither is better and both are valid merge bases.” Apply this procedure: Use –all, count output lines and build an explicit policy for zero, one or many bases. The expected mechanism is: A count greater than one is a legitimate graph result, not corruption; downstream code must not pretend the base is uniquely defined. For the group assignment, add one near-miss that exposes writing a script that silently accepts one arbitrary base when semantics require every best base. The answer is complete only when it says why the near-miss fails and how the corrected model transfers to a different project without relying on the original variable names.
Case 2: documentation repo. Contrast the rule using release, translation and correction branches compared before integration. State the input grain or object graph, the chapter boundary and the intended output before choosing syntax. Change only one variable, so a wrong prediction has a single plausible cause.
Reasoned route. Begin with “With criss-cross merging, two common ancestors can be incomparable, so neither is better and both are valid merge bases.” Apply this procedure: Use –all, count output lines and build an explicit policy for zero, one or many bases. The expected mechanism is: A count greater than one is a legitimate graph result, not corruption; downstream code must not pretend the base is uniquely defined. For the documentation repo, add one near-miss that exposes writing a script that silently accepts one arbitrary base when semantics require every best base. The answer is complete only when it says why the near-miss fails and how the corrected model transfers to a different project without relying on the original variable names.
Case 3: robotics project. Stress-test the rule using several topic tips reduced to independent work lines. State the input grain or object graph, the chapter boundary and the intended output before choosing syntax. Change only one variable, so a wrong prediction has a single plausible cause.
Reasoned route. Begin with “With criss-cross merging, two common ancestors can be incomparable, so neither is better and both are valid merge bases.” Apply this procedure: Use –all, count output lines and build an explicit policy for zero, one or many bases. The expected mechanism is: A count greater than one is a legitimate graph result, not corruption; downstream code must not pretend the base is uniquely defined. For the robotics project, add one near-miss that exposes writing a script that silently accepts one arbitrary base when semantics require every best base. The answer is complete only when it says why the near-miss fails and how the corrected model transfers to a different project without relying on the original variable names.
Case 4: revision repository. Explain the rule using shallow clone whose missing parents change what ancestry is visible. State the input grain or object graph, the chapter boundary and the intended output before choosing syntax. Change only one variable, so a wrong prediction has a single plausible cause.
Reasoned route. Begin with “With criss-cross merging, two common ancestors can be incomparable, so neither is better and both are valid merge bases.” Apply this procedure: Use –all, count output lines and build an explicit policy for zero, one or many bases. The expected mechanism is: A count greater than one is a legitimate graph result, not corruption; downstream code must not pretend the base is uniquely defined. For the revision repository, add one near-miss that exposes writing a script that silently accepts one arbitrary base when semantics require every best base. The answer is complete only when it says why the near-miss fails and how the corrected model transfers to a different project without relying on the original variable names.
Diagnostic route
- Model check: ask the learner to draw or list the exact rows, fields, references, paths or states involved.
- Boundary check: create the smallest input that triggers writing a script that silently accepts one arbitrary base when semantics require every best base.
- Evidence check: separate a printed value from identity, ordering, ownership, type or repository state.
- Repair check: use the reversible procedure “Use –all, count output lines and build an explicit policy for zero, one or many bases.” and record the first changed observation.
- Transfer check: repeat the rule in a second context and identify what remains invariant.
A parent does not need to know the final Git merge-base syntax. For this chapter, useful prompts are: “What did you expect from Criss-cross histories can have multiple best bases?”, “Which state changed first?”, “What evidence tests that prediction?”, and “Can the case exposing writing a script that silently accepts one arbitrary base when semantics require every best base be made smaller?” The learner, not the parent, should supply the technical explanation.
Practice with an explained answer
Question. Build a tiny group assignment with parallel merges that produce a criss-cross ancestry pattern. Include one ordinary case, one boundary and one deliberate failure caused by writing a script that silently accepts one arbitrary base when semantics require every best base. Predict each result before using a tool, then report the first point where observation differs from prediction.
Answer guide. A strong response starts with the rule: With criss-cross merging, two common ancestors can be incomparable, so neither is better and both are valid merge bases. It shows a trace, not only a final value. The ordinary case should demonstrate “A count greater than one is a legitimate graph result, not corruption; downstream code must not pretend the base is uniquely defined.” The boundary must exercise the same mechanism at an edge, and the deliberate failure must be repaired with: Use –all, count output lines and build an explicit policy for zero, one or many bases. Other data choices are valid when the evidence supports the same causal chain.
Decision and transfer
For Criss-cross histories can have multiple best bases, separate the documented Git merge-base mechanism from the project policy. State exactly what the technical contract guarantees, then state the project choice about validation, ordering, ownership, performance or recovery. Test whether the same distinction survives one transfer case, and keep stateful experiments disposable and backed up.
Previous chapter . Contents . Next chapter
Without –all, merge-base may output one best base when several exist; –all requests all merge bases. Treat that sentence as a testable model. A secure learner can point to the relevant input, name the operation, describe the resulting state and identify one observation that would prove the model incomplete.
The high-value mistake in this chapter is believing default single-line output proves uniqueness. It matters because the output may look reasonable while the ownership, ordering, identity or safety rule is wrong. Run both forms on a rehearsed criss-cross repository and compare sets, not only the first line.
For the –all preserves every best answer chapter on Git merge-base, use a two-column trace during a short Punggol home session. On the left, write the predicted state for this exact mechanism before the tool runs. On the right, record the observation that bears on believing default single-line output proves uniqueness. Explain the earliest difference with one causal sentence, then repeat only the smallest changed case.
Core worked example
git merge-base left right
git merge-base --all left rightExplained result. The second command is the uniqueness test: one line confirms one visible best base, while several lines expose ambiguity the default form can hide. Check the boundary as well as the happy path: ask what happens with an empty input, a duplicate or tied value, an unsupported type, a missing path, a NULL, or a second reference to the same object. Only the relevant boundary should be kept; the list is a prompt for judgment, not a demand to force every case into every example.
Four purposeful transfer cases
Case 1: robotics project. Contrast the rule using several topic tips reduced to independent work lines. State the input grain or object graph, the chapter boundary and the intended output before choosing syntax. Change only one variable, so a wrong prediction has a single plausible cause.
Reasoned route. Begin with “Without –all, merge-base may output one best base when several exist; –all requests all merge bases.” Apply this procedure: Run both forms on a rehearsed criss-cross repository and compare sets, not only the first line. The expected mechanism is: The second command is the uniqueness test: one line confirms one visible best base, while several lines expose ambiguity the default form can hide. For the robotics project, add one near-miss that exposes believing default single-line output proves uniqueness. The answer is complete only when it says why the near-miss fails and how the corrected model transfers to a different project without relying on the original variable names.
Case 2: revision repository. Stress-test the rule using shallow clone whose missing parents change what ancestry is visible. State the input grain or object graph, the chapter boundary and the intended output before choosing syntax. Change only one variable, so a wrong prediction has a single plausible cause.
Reasoned route. Begin with “Without –all, merge-base may output one best base when several exist; –all requests all merge bases.” Apply this procedure: Run both forms on a rehearsed criss-cross repository and compare sets, not only the first line. The expected mechanism is: The second command is the uniqueness test: one line confirms one visible best base, while several lines expose ambiguity the default form can hide. For the revision repository, add one near-miss that exposes believing default single-line output proves uniqueness. The answer is complete only when it says why the near-miss fails and how the corrected model transfers to a different project without relying on the original variable names.
Case 3: test laboratory. Explain the rule using ordinary, ancestor, unrelated, criss-cross, reflog and expired-reflog histories. State the input grain or object graph, the chapter boundary and the intended output before choosing syntax. Change only one variable, so a wrong prediction has a single plausible cause.
Reasoned route. Begin with “Without –all, merge-base may output one best base when several exist; –all requests all merge bases.” Apply this procedure: Run both forms on a rehearsed criss-cross repository and compare sets, not only the first line. The expected mechanism is: The second command is the uniqueness test: one line confirms one visible best base, while several lines expose ambiguity the default form can hide. For the test laboratory, add one near-miss that exposes believing default single-line output proves uniqueness. The answer is complete only when it says why the near-miss fails and how the corrected model transfers to a different project without relying on the original variable names.
Case 4: design review. Transfer the rule using merge-base compared with fork-point, three-dot diff and merge-tree inputs. State the input grain or object graph, the chapter boundary and the intended output before choosing syntax. Change only one variable, so a wrong prediction has a single plausible cause.
Reasoned route. Begin with “Without –all, merge-base may output one best base when several exist; –all requests all merge bases.” Apply this procedure: Run both forms on a rehearsed criss-cross repository and compare sets, not only the first line. The expected mechanism is: The second command is the uniqueness test: one line confirms one visible best base, while several lines expose ambiguity the default form can hide. For the design review, add one near-miss that exposes believing default single-line output proves uniqueness. The answer is complete only when it says why the near-miss fails and how the corrected model transfers to a different project without relying on the original variable names.
Diagnostic route
- Model check: ask the learner to draw or list the exact rows, fields, references, paths or states involved.
- Boundary check: create the smallest input that triggers believing default single-line output proves uniqueness.
- Evidence check: separate a printed value from identity, ordering, ownership, type or repository state.
- Repair check: use the reversible procedure “Run both forms on a rehearsed criss-cross repository and compare sets, not only the first line.” and record the first changed observation.
- Transfer check: repeat the rule in a second context and identify what remains invariant.
A parent does not need to know the final Git merge-base syntax. For this chapter, useful prompts are: “What did you expect from –all preserves every best answer?”, “Which state changed first?”, “What evidence tests that prediction?”, and “Can the case exposing believing default single-line output proves uniqueness be made smaller?” The learner, not the parent, should supply the technical explanation.
Practice with an explained answer
Question. Build a tiny documentation repo with release, translation and correction branches compared before integration. Include one ordinary case, one boundary and one deliberate failure caused by believing default single-line output proves uniqueness. Predict each result before using a tool, then report the first point where observation differs from prediction.
Answer guide. A strong response starts with the rule: Without –all, merge-base may output one best base when several exist; –all requests all merge bases. It shows a trace, not only a final value. The ordinary case should demonstrate “The second command is the uniqueness test: one line confirms one visible best base, while several lines expose ambiguity the default form can hide.” The boundary must exercise the same mechanism at an edge, and the deliberate failure must be repaired with: Run both forms on a rehearsed criss-cross repository and compare sets, not only the first line. Other data choices are valid when the evidence supports the same causal chain.
Decision and transfer
For –all preserves every best answer, separate the documented Git merge-base mechanism from the project policy. State exactly what the technical contract guarantees, then state the project choice about validation, ordering, ownership, performance or recovery. Test whether the same distinction survives one transfer case, and keep stateful experiments disposable and backed up.
Previous chapter . Contents . Next chapter
With two commits, merge-base directly computes their best common ancestors and is the safest form for teaching ordinary divergence. Treat that sentence as a testable model. A secure learner can point to the relevant input, name the operation, describe the resulting state and identify one observation that would prove the model incomplete.
The high-value mistake in this chapter is generalising the two-argument mental model unchanged to an arbitrary argument list. It matters because the output may look reasonable while the ownership, ordering, identity or safety rule is wrong. Master two-tip graphs first, then state the documented hypothetical-merge rule before adding a third commit.
For the Two arguments are the clearest special case chapter on Git merge-base, use a two-column trace during a short Punggol home session. On the left, write the predicted state for this exact mechanism before the tool runs. On the right, record the observation that bears on generalising the two-argument mental model unchanged to an arbitrary argument list. Explain the earliest difference with one causal sentence, then repeat only the smallest changed case.
Core worked example
git merge-base --all A BExplained result. Every returned commit is reachable from A and B and is not an ancestor of another returned common ancestor. Check the boundary as well as the happy path: ask what happens with an empty input, a duplicate or tied value, an unsupported type, a missing path, a NULL, or a second reference to the same object. Only the relevant boundary should be kept; the list is a prompt for judgment, not a demand to force every case into every example.
Four purposeful transfer cases
Case 1: test laboratory. Stress-test the rule using ordinary, ancestor, unrelated, criss-cross, reflog and expired-reflog histories. State the input grain or object graph, the chapter boundary and the intended output before choosing syntax. Change only one variable, so a wrong prediction has a single plausible cause.
Reasoned route. Begin with “With two commits, merge-base directly computes their best common ancestors and is the safest form for teaching ordinary divergence.” Apply this procedure: Master two-tip graphs first, then state the documented hypothetical-merge rule before adding a third commit. The expected mechanism is: Every returned commit is reachable from A and B and is not an ancestor of another returned common ancestor. For the test laboratory, add one near-miss that exposes generalising the two-argument mental model unchanged to an arbitrary argument list. The answer is complete only when it says why the near-miss fails and how the corrected model transfers to a different project without relying on the original variable names.
Case 2: design review. Explain the rule using merge-base compared with fork-point, three-dot diff and merge-tree inputs. State the input grain or object graph, the chapter boundary and the intended output before choosing syntax. Change only one variable, so a wrong prediction has a single plausible cause.
Reasoned route. Begin with “With two commits, merge-base directly computes their best common ancestors and is the safest form for teaching ordinary divergence.” Apply this procedure: Master two-tip graphs first, then state the documented hypothetical-merge rule before adding a third commit. The expected mechanism is: Every returned commit is reachable from A and B and is not an ancestor of another returned common ancestor. For the design review, add one near-miss that exposes generalising the two-argument mental model unchanged to an arbitrary argument list. The answer is complete only when it says why the near-miss fails and how the corrected model transfers to a different project without relying on the original variable names.
Case 3: school coding project. Transfer the rule using main, report and experiment branches with ordinary divergence. State the input grain or object graph, the chapter boundary and the intended output before choosing syntax. Change only one variable, so a wrong prediction has a single plausible cause.
Reasoned route. Begin with “With two commits, merge-base directly computes their best common ancestors and is the safest form for teaching ordinary divergence.” Apply this procedure: Master two-tip graphs first, then state the documented hypothetical-merge rule before adding a third commit. The expected mechanism is: Every returned commit is reachable from A and B and is not an ancestor of another returned common ancestor. For the school coding project, add one near-miss that exposes generalising the two-argument mental model unchanged to an arbitrary argument list. The answer is complete only when it says why the near-miss fails and how the corrected model transfers to a different project without relying on the original variable names.
Case 4: CCA website. Predict the rule using a feature branch rebased after the remote-tracking branch moved. State the input grain or object graph, the chapter boundary and the intended output before choosing syntax. Change only one variable, so a wrong prediction has a single plausible cause.
Reasoned route. Begin with “With two commits, merge-base directly computes their best common ancestors and is the safest form for teaching ordinary divergence.” Apply this procedure: Master two-tip graphs first, then state the documented hypothetical-merge rule before adding a third commit. The expected mechanism is: Every returned commit is reachable from A and B and is not an ancestor of another returned common ancestor. For the CCA website, add one near-miss that exposes generalising the two-argument mental model unchanged to an arbitrary argument list. The answer is complete only when it says why the near-miss fails and how the corrected model transfers to a different project without relying on the original variable names.
Diagnostic route
- Model check: ask the learner to draw or list the exact rows, fields, references, paths or states involved.
- Boundary check: create the smallest input that triggers generalising the two-argument mental model unchanged to an arbitrary argument list.
- Evidence check: separate a printed value from identity, ordering, ownership, type or repository state.
- Repair check: use the reversible procedure “Master two-tip graphs first, then state the documented hypothetical-merge rule before adding a third commit.” and record the first changed observation.
- Transfer check: repeat the rule in a second context and identify what remains invariant.
A parent does not need to know the final Git merge-base syntax. For this chapter, useful prompts are: “What did you expect from Two arguments are the clearest special case?”, “Which state changed first?”, “What evidence tests that prediction?”, and “Can the case exposing generalising the two-argument mental model unchanged to an arbitrary argument list be made smaller?” The learner, not the parent, should supply the technical explanation.
Practice with an explained answer
Question. Build a tiny robotics project with several topic tips reduced to independent work lines. Include one ordinary case, one boundary and one deliberate failure caused by generalising the two-argument mental model unchanged to an arbitrary argument list. Predict each result before using a tool, then report the first point where observation differs from prediction.
Answer guide. A strong response starts with the rule: With two commits, merge-base directly computes their best common ancestors and is the safest form for teaching ordinary divergence. It shows a trace, not only a final value. The ordinary case should demonstrate “Every returned commit is reachable from A and B and is not an ancestor of another returned common ancestor.” The boundary must exercise the same mechanism at an edge, and the deliberate failure must be repaired with: Master two-tip graphs first, then state the documented hypothetical-merge rule before adding a third commit. Other data choices are valid when the evidence supports the same causal chain.
Decision and transfer
For Two arguments are the clearest special case, separate the documented Git merge-base mechanism from the project policy. State exactly what the technical contract guarantees, then state the project choice about validation, ordering, ownership, performance or recovery. Test whether the same distinction survives one transfer case, and keep stateful experiments disposable and backed up.
Previous chapter . Contents . Next chapter
CHAPTER 9 OF 20 . Handle boundaries
9. More than two arguments use a hypothetical merge
In the general multi-argument form, the first commit is compared with a hypothetical merge of the remaining commits, so the result need not be contained in every remaining argument. Treat that sentence as a testable model. A secure learner can point to the relevant input, name the operation, describe the resulting state and identify one observation that would prove the model incomplete.
The high-value mistake in this chapter is assuming git merge-base A B C means intersection of ancestors of all three tips. It matters because the output may look reasonable while the ownership, ordering, identity or safety rule is wrong. Compare the general form with –octopus on a graph designed so their results differ.
For the More than two arguments use a hypothetical merge chapter on Git merge-base, use a two-column trace during a short Punggol home session. On the left, write the predicted state for this exact mechanism before the tool runs. On the right, record the observation that bears on assuming git merge-base A B C means intersection of ancestors of all three tips. Explain the earliest difference with one causal sentence, then repeat only the smallest changed case.
Core worked example
git merge-base A B C
git merge-base --octopus A B CExplained result. Different output is possible because the first form uses the documented hypothetical merge model while –octopus asks for best common ancestors of all supplied commits. Check the boundary as well as the happy path: ask what happens with an empty input, a duplicate or tied value, an unsupported type, a missing path, a NULL, or a second reference to the same object. Only the relevant boundary should be kept; the list is a prompt for judgment, not a demand to force every case into every example.
Four purposeful transfer cases
Case 1: school coding project. Explain the rule using main, report and experiment branches with ordinary divergence. State the input grain or object graph, the chapter boundary and the intended output before choosing syntax. Change only one variable, so a wrong prediction has a single plausible cause.
Reasoned route. Begin with “In the general multi-argument form, the first commit is compared with a hypothetical merge of the remaining commits, so the result need not be contained in every remaining argument.” Apply this procedure: Compare the general form with –octopus on a graph designed so their results differ. The expected mechanism is: Different output is possible because the first form uses the documented hypothetical merge model while –octopus asks for best common ancestors of all supplied commits. For the school coding project, add one near-miss that exposes assuming git merge-base A B C means intersection of ancestors of all three tips. The answer is complete only when it says why the near-miss fails and how the corrected model transfers to a different project without relying on the original variable names.
Case 2: CCA website. Transfer the rule using a feature branch rebased after the remote-tracking branch moved. State the input grain or object graph, the chapter boundary and the intended output before choosing syntax. Change only one variable, so a wrong prediction has a single plausible cause.
Reasoned route. Begin with “In the general multi-argument form, the first commit is compared with a hypothetical merge of the remaining commits, so the result need not be contained in every remaining argument.” Apply this procedure: Compare the general form with –octopus on a graph designed so their results differ. The expected mechanism is: Different output is possible because the first form uses the documented hypothetical merge model while –octopus asks for best common ancestors of all supplied commits. For the CCA website, add one near-miss that exposes assuming git merge-base A B C means intersection of ancestors of all three tips. The answer is complete only when it says why the near-miss fails and how the corrected model transfers to a different project without relying on the original variable names.
Case 3: group assignment. Predict the rule using parallel merges that produce a criss-cross ancestry pattern. State the input grain or object graph, the chapter boundary and the intended output before choosing syntax. Change only one variable, so a wrong prediction has a single plausible cause.
Reasoned route. Begin with “In the general multi-argument form, the first commit is compared with a hypothetical merge of the remaining commits, so the result need not be contained in every remaining argument.” Apply this procedure: Compare the general form with –octopus on a graph designed so their results differ. The expected mechanism is: Different output is possible because the first form uses the documented hypothetical merge model while –octopus asks for best common ancestors of all supplied commits. For the group assignment, add one near-miss that exposes assuming git merge-base A B C means intersection of ancestors of all three tips. The answer is complete only when it says why the near-miss fails and how the corrected model transfers to a different project without relying on the original variable names.
Case 4: documentation repo. Contrast the rule using release, translation and correction branches compared before integration. State the input grain or object graph, the chapter boundary and the intended output before choosing syntax. Change only one variable, so a wrong prediction has a single plausible cause.
Reasoned route. Begin with “In the general multi-argument form, the first commit is compared with a hypothetical merge of the remaining commits, so the result need not be contained in every remaining argument.” Apply this procedure: Compare the general form with –octopus on a graph designed so their results differ. The expected mechanism is: Different output is possible because the first form uses the documented hypothetical merge model while –octopus asks for best common ancestors of all supplied commits. For the documentation repo, add one near-miss that exposes assuming git merge-base A B C means intersection of ancestors of all three tips. The answer is complete only when it says why the near-miss fails and how the corrected model transfers to a different project without relying on the original variable names.
Diagnostic route
- Model check: ask the learner to draw or list the exact rows, fields, references, paths or states involved.
- Boundary check: create the smallest input that triggers assuming git merge-base A B C means intersection of ancestors of all three tips.
- Evidence check: separate a printed value from identity, ordering, ownership, type or repository state.
- Repair check: use the reversible procedure “Compare the general form with –octopus on a graph designed so their results differ.” and record the first changed observation.
- Transfer check: repeat the rule in a second context and identify what remains invariant.
A parent does not need to know the final Git merge-base syntax. For this chapter, useful prompts are: “What did you expect from More than two arguments use a hypothetical merge?”, “Which state changed first?”, “What evidence tests that prediction?”, and “Can the case exposing assuming git merge-base A B C means intersection of ancestors of all three tips be made smaller?” The learner, not the parent, should supply the technical explanation.
Practice with an explained answer
Question. Build a tiny revision repository with shallow clone whose missing parents change what ancestry is visible. Include one ordinary case, one boundary and one deliberate failure caused by assuming git merge-base A B C means intersection of ancestors of all three tips. Predict each result before using a tool, then report the first point where observation differs from prediction.
Answer guide. A strong response starts with the rule: In the general multi-argument form, the first commit is compared with a hypothetical merge of the remaining commits, so the result need not be contained in every remaining argument. It shows a trace, not only a final value. The ordinary case should demonstrate “Different output is possible because the first form uses the documented hypothetical merge model while –octopus asks for best common ancestors of all supplied commits.” The boundary must exercise the same mechanism at an edge, and the deliberate failure must be repaired with: Compare the general form with –octopus on a graph designed so their results differ. Other data choices are valid when the evidence supports the same causal chain.
Decision and transfer
For More than two arguments use a hypothetical merge, separate the documented Git merge-base mechanism from the project policy. State exactly what the technical contract guarantees, then state the project choice about validation, ordering, ownership, performance or recovery. Test whether the same distinction survives one transfer case, and keep stateful experiments disposable and backed up.
Previous chapter . Contents . Next chapter
The –octopus mode computes best common ancestors of all supplied commits in preparation for an n-way merge. Treat that sentence as a testable model. A secure learner can point to the relevant input, name the operation, describe the resulting state and identify one observation that would prove the model incomplete.
The high-value mistake in this chapter is using repeated pairwise merge-base calls and assuming the order cannot affect the reduced answer. It matters because the output may look reasonable while the ownership, ordering, identity or safety rule is wrong. Draw the full graph and compare one –octopus call with several pairwise reductions.
For the –octopus finds bases for an n-way merge chapter on Git merge-base, use a two-column trace during a short Punggol home session. On the left, write the predicted state for this exact mechanism before the tool runs. On the right, record the observation that bears on using repeated pairwise merge-base calls and assuming the order cannot affect the reduced answer. Explain the earliest difference with one causal sentence, then repeat only the smallest changed case.
Core worked example
git merge-base --octopus main topic-a topic-bExplained result. The output represents common ancestry for all three tips under octopus semantics rather than whichever pair happened to be reduced first. Check the boundary as well as the happy path: ask what happens with an empty input, a duplicate or tied value, an unsupported type, a missing path, a NULL, or a second reference to the same object. Only the relevant boundary should be kept; the list is a prompt for judgment, not a demand to force every case into every example.
Four purposeful transfer cases
Case 1: group assignment. Transfer the rule using parallel merges that produce a criss-cross ancestry pattern. State the input grain or object graph, the chapter boundary and the intended output before choosing syntax. Change only one variable, so a wrong prediction has a single plausible cause.
Reasoned route. Begin with “The –octopus mode computes best common ancestors of all supplied commits in preparation for an n-way merge.” Apply this procedure: Draw the full graph and compare one –octopus call with several pairwise reductions. The expected mechanism is: The output represents common ancestry for all three tips under octopus semantics rather than whichever pair happened to be reduced first. For the group assignment, add one near-miss that exposes using repeated pairwise merge-base calls and assuming the order cannot affect the reduced answer. The answer is complete only when it says why the near-miss fails and how the corrected model transfers to a different project without relying on the original variable names.
Case 2: documentation repo. Predict the rule using release, translation and correction branches compared before integration. State the input grain or object graph, the chapter boundary and the intended output before choosing syntax. Change only one variable, so a wrong prediction has a single plausible cause.
Reasoned route. Begin with “The –octopus mode computes best common ancestors of all supplied commits in preparation for an n-way merge.” Apply this procedure: Draw the full graph and compare one –octopus call with several pairwise reductions. The expected mechanism is: The output represents common ancestry for all three tips under octopus semantics rather than whichever pair happened to be reduced first. For the documentation repo, add one near-miss that exposes using repeated pairwise merge-base calls and assuming the order cannot affect the reduced answer. The answer is complete only when it says why the near-miss fails and how the corrected model transfers to a different project without relying on the original variable names.
Case 3: robotics project. Contrast the rule using several topic tips reduced to independent work lines. State the input grain or object graph, the chapter boundary and the intended output before choosing syntax. Change only one variable, so a wrong prediction has a single plausible cause.
Reasoned route. Begin with “The –octopus mode computes best common ancestors of all supplied commits in preparation for an n-way merge.” Apply this procedure: Draw the full graph and compare one –octopus call with several pairwise reductions. The expected mechanism is: The output represents common ancestry for all three tips under octopus semantics rather than whichever pair happened to be reduced first. For the robotics project, add one near-miss that exposes using repeated pairwise merge-base calls and assuming the order cannot affect the reduced answer. The answer is complete only when it says why the near-miss fails and how the corrected model transfers to a different project without relying on the original variable names.
Case 4: revision repository. Stress-test the rule using shallow clone whose missing parents change what ancestry is visible. State the input grain or object graph, the chapter boundary and the intended output before choosing syntax. Change only one variable, so a wrong prediction has a single plausible cause.
Reasoned route. Begin with “The –octopus mode computes best common ancestors of all supplied commits in preparation for an n-way merge.” Apply this procedure: Draw the full graph and compare one –octopus call with several pairwise reductions. The expected mechanism is: The output represents common ancestry for all three tips under octopus semantics rather than whichever pair happened to be reduced first. For the revision repository, add one near-miss that exposes using repeated pairwise merge-base calls and assuming the order cannot affect the reduced answer. The answer is complete only when it says why the near-miss fails and how the corrected model transfers to a different project without relying on the original variable names.
Diagnostic route
- Model check: ask the learner to draw or list the exact rows, fields, references, paths or states involved.
- Boundary check: create the smallest input that triggers using repeated pairwise merge-base calls and assuming the order cannot affect the reduced answer.
- Evidence check: separate a printed value from identity, ordering, ownership, type or repository state.
- Repair check: use the reversible procedure “Draw the full graph and compare one –octopus call with several pairwise reductions.” and record the first changed observation.
- Transfer check: repeat the rule in a second context and identify what remains invariant.
A parent does not need to know the final Git merge-base syntax. For this chapter, useful prompts are: “What did you expect from –octopus finds bases for an n-way merge?”, “Which state changed first?”, “What evidence tests that prediction?”, and “Can the case exposing using repeated pairwise merge-base calls and assuming the order cannot affect the reduced answer be made smaller?” The learner, not the parent, should supply the technical explanation.
Practice with an explained answer
Question. Build a tiny test laboratory with ordinary, ancestor, unrelated, criss-cross, reflog and expired-reflog histories. Include one ordinary case, one boundary and one deliberate failure caused by using repeated pairwise merge-base calls and assuming the order cannot affect the reduced answer. Predict each result before using a tool, then report the first point where observation differs from prediction.
Answer guide. A strong response starts with the rule: The –octopus mode computes best common ancestors of all supplied commits in preparation for an n-way merge. It shows a trace, not only a final value. The ordinary case should demonstrate “The output represents common ancestry for all three tips under octopus semantics rather than whichever pair happened to be reduced first.” The boundary must exercise the same mechanism at an edge, and the deliberate failure must be repaired with: Draw the full graph and compare one –octopus call with several pairwise reductions. Other data choices are valid when the evidence supports the same causal chain.
Decision and transfer
For –octopus finds bases for an n-way merge, separate the documented Git merge-base mechanism from the project policy. State exactly what the technical contract guarantees, then state the project choice about validation, ordering, ownership, performance or recovery. Test whether the same distinction survives one transfer case, and keep stateful experiments disposable and backed up.
Previous chapter . Contents . Next chapter
CHAPTER 11 OF 20 . Handle boundaries
11. –is-ancestor answers reachability through status
git merge-base –is-ancestor A B exits 0 when A is an ancestor of B and 1 when it is not, normally producing no explanatory hash. Treat that sentence as a testable model. A secure learner can point to the relevant input, name the operation, describe the resulting state and identify one observation that would prove the model incomplete.
The high-value mistake in this chapter is parsing stdout or treating every nonzero status as the ordinary false case. It matters because the output may look reasonable while the ownership, ordering, identity or safety rule is wrong. Capture the exit code immediately and distinguish 1 from other errors such as an invalid revision.
For the –is-ancestor answers reachability through status chapter on Git merge-base, use a two-column trace during a short Punggol home session. On the left, write the predicted state for this exact mechanism before the tool runs. On the right, record the observation that bears on parsing stdout or treating every nonzero status as the ordinary false case. Explain the earliest difference with one causal sentence, then repeat only the smallest changed case.
Core worked example
if git merge-base --is-ancestor release main; then
echo reachable
else
status=$?; echo "status=$status"
fiExplained result. Status 0 means reachable; status 1 means a valid negative ancestry result, while larger error statuses require separate handling. Check the boundary as well as the happy path: ask what happens with an empty input, a duplicate or tied value, an unsupported type, a missing path, a NULL, or a second reference to the same object. Only the relevant boundary should be kept; the list is a prompt for judgment, not a demand to force every case into every example.
Four purposeful transfer cases
Case 1: robotics project. Predict the rule using several topic tips reduced to independent work lines. State the input grain or object graph, the chapter boundary and the intended output before choosing syntax. Change only one variable, so a wrong prediction has a single plausible cause.
Reasoned route. Begin with “git merge-base –is-ancestor A B exits 0 when A is an ancestor of B and 1 when it is not, normally producing no explanatory hash.” Apply this procedure: Capture the exit code immediately and distinguish 1 from other errors such as an invalid revision. The expected mechanism is: Status 0 means reachable; status 1 means a valid negative ancestry result, while larger error statuses require separate handling. For the robotics project, add one near-miss that exposes parsing stdout or treating every nonzero status as the ordinary false case. The answer is complete only when it says why the near-miss fails and how the corrected model transfers to a different project without relying on the original variable names.
Case 2: revision repository. Contrast the rule using shallow clone whose missing parents change what ancestry is visible. State the input grain or object graph, the chapter boundary and the intended output before choosing syntax. Change only one variable, so a wrong prediction has a single plausible cause.
Reasoned route. Begin with “git merge-base –is-ancestor A B exits 0 when A is an ancestor of B and 1 when it is not, normally producing no explanatory hash.” Apply this procedure: Capture the exit code immediately and distinguish 1 from other errors such as an invalid revision. The expected mechanism is: Status 0 means reachable; status 1 means a valid negative ancestry result, while larger error statuses require separate handling. For the revision repository, add one near-miss that exposes parsing stdout or treating every nonzero status as the ordinary false case. The answer is complete only when it says why the near-miss fails and how the corrected model transfers to a different project without relying on the original variable names.
Case 3: test laboratory. Stress-test the rule using ordinary, ancestor, unrelated, criss-cross, reflog and expired-reflog histories. State the input grain or object graph, the chapter boundary and the intended output before choosing syntax. Change only one variable, so a wrong prediction has a single plausible cause.
Reasoned route. Begin with “git merge-base –is-ancestor A B exits 0 when A is an ancestor of B and 1 when it is not, normally producing no explanatory hash.” Apply this procedure: Capture the exit code immediately and distinguish 1 from other errors such as an invalid revision. The expected mechanism is: Status 0 means reachable; status 1 means a valid negative ancestry result, while larger error statuses require separate handling. For the test laboratory, add one near-miss that exposes parsing stdout or treating every nonzero status as the ordinary false case. The answer is complete only when it says why the near-miss fails and how the corrected model transfers to a different project without relying on the original variable names.
Case 4: design review. Explain the rule using merge-base compared with fork-point, three-dot diff and merge-tree inputs. State the input grain or object graph, the chapter boundary and the intended output before choosing syntax. Change only one variable, so a wrong prediction has a single plausible cause.
Reasoned route. Begin with “git merge-base –is-ancestor A B exits 0 when A is an ancestor of B and 1 when it is not, normally producing no explanatory hash.” Apply this procedure: Capture the exit code immediately and distinguish 1 from other errors such as an invalid revision. The expected mechanism is: Status 0 means reachable; status 1 means a valid negative ancestry result, while larger error statuses require separate handling. For the design review, add one near-miss that exposes parsing stdout or treating every nonzero status as the ordinary false case. The answer is complete only when it says why the near-miss fails and how the corrected model transfers to a different project without relying on the original variable names.
Diagnostic route
- Model check: ask the learner to draw or list the exact rows, fields, references, paths or states involved.
- Boundary check: create the smallest input that triggers parsing stdout or treating every nonzero status as the ordinary false case.
- Evidence check: separate a printed value from identity, ordering, ownership, type or repository state.
- Repair check: use the reversible procedure “Capture the exit code immediately and distinguish 1 from other errors such as an invalid revision.” and record the first changed observation.
- Transfer check: repeat the rule in a second context and identify what remains invariant.
A parent does not need to know the final Git merge-base syntax. For this chapter, useful prompts are: “What did you expect from –is-ancestor answers reachability through status?”, “Which state changed first?”, “What evidence tests that prediction?”, and “Can the case exposing parsing stdout or treating every nonzero status as the ordinary false case be made smaller?” The learner, not the parent, should supply the technical explanation.
Practice with an explained answer
Question. Build a tiny design review with merge-base compared with fork-point, three-dot diff and merge-tree inputs. Include one ordinary case, one boundary and one deliberate failure caused by parsing stdout or treating every nonzero status as the ordinary false case. Predict each result before using a tool, then report the first point where observation differs from prediction.
Answer guide. A strong response starts with the rule: git merge-base –is-ancestor A B exits 0 when A is an ancestor of B and 1 when it is not, normally producing no explanatory hash. It shows a trace, not only a final value. The ordinary case should demonstrate “Status 0 means reachable; status 1 means a valid negative ancestry result, while larger error statuses require separate handling.” The boundary must exercise the same mechanism at an edge, and the deliberate failure must be repaired with: Capture the exit code immediately and distinguish 1 from other errors such as an invalid revision. Other data choices are valid when the evidence supports the same causal chain.
Decision and transfer
For –is-ancestor answers reachability through status, separate the documented Git merge-base mechanism from the project policy. State exactly what the technical contract guarantees, then state the project choice about validation, ordering, ownership, performance or recovery. Test whether the same distinction survives one transfer case, and keep stateful experiments disposable and backed up.
Previous chapter . Contents . Next chapter
CHAPTER 12 OF 20 . Handle boundaries
12. Ancestor tests make safer fast-forward gates
A deployment or update gate can require the current release to be an ancestor of the proposed tip before allowing a fast-forward-only move. Treat that sentence as a testable model. A secure learner can point to the relevant input, name the operation, describe the resulting state and identify one observation that would prove the model incomplete.
The high-value mistake in this chapter is comparing commit hashes directly and rejecting legitimate descendants. It matters because the output may look reasonable while the ownership, ordering, identity or safety rule is wrong. Verify both revisions exist, run –is-ancestor and perform the actual update with its own fast-forward protection.
For the Ancestor tests make safer fast-forward gates chapter on Git merge-base, use a two-column trace during a short Punggol home session. On the left, write the predicted state for this exact mechanism before the tool runs. On the right, record the observation that bears on comparing commit hashes directly and rejecting legitimate descendants. Explain the earliest difference with one causal sentence, then repeat only the smallest changed case.
Core worked example
git merge-base --is-ancestor refs/tags/release refs/remotes/origin/main
git merge --ff-only refs/remotes/origin/mainExplained result. The first command tests reachability; the second still enforces integration policy, so a stale check cannot replace the protected operation. Check the boundary as well as the happy path: ask what happens with an empty input, a duplicate or tied value, an unsupported type, a missing path, a NULL, or a second reference to the same object. Only the relevant boundary should be kept; the list is a prompt for judgment, not a demand to force every case into every example.
Four purposeful transfer cases
Case 1: test laboratory. Contrast the rule using ordinary, ancestor, unrelated, criss-cross, reflog and expired-reflog histories. State the input grain or object graph, the chapter boundary and the intended output before choosing syntax. Change only one variable, so a wrong prediction has a single plausible cause.
Reasoned route. Begin with “A deployment or update gate can require the current release to be an ancestor of the proposed tip before allowing a fast-forward-only move.” Apply this procedure: Verify both revisions exist, run –is-ancestor and perform the actual update with its own fast-forward protection. The expected mechanism is: The first command tests reachability; the second still enforces integration policy, so a stale check cannot replace the protected operation. For the test laboratory, add one near-miss that exposes comparing commit hashes directly and rejecting legitimate descendants. The answer is complete only when it says why the near-miss fails and how the corrected model transfers to a different project without relying on the original variable names.
Case 2: design review. Stress-test the rule using merge-base compared with fork-point, three-dot diff and merge-tree inputs. State the input grain or object graph, the chapter boundary and the intended output before choosing syntax. Change only one variable, so a wrong prediction has a single plausible cause.
Reasoned route. Begin with “A deployment or update gate can require the current release to be an ancestor of the proposed tip before allowing a fast-forward-only move.” Apply this procedure: Verify both revisions exist, run –is-ancestor and perform the actual update with its own fast-forward protection. The expected mechanism is: The first command tests reachability; the second still enforces integration policy, so a stale check cannot replace the protected operation. For the design review, add one near-miss that exposes comparing commit hashes directly and rejecting legitimate descendants. The answer is complete only when it says why the near-miss fails and how the corrected model transfers to a different project without relying on the original variable names.
Case 3: school coding project. Explain the rule using main, report and experiment branches with ordinary divergence. State the input grain or object graph, the chapter boundary and the intended output before choosing syntax. Change only one variable, so a wrong prediction has a single plausible cause.
Reasoned route. Begin with “A deployment or update gate can require the current release to be an ancestor of the proposed tip before allowing a fast-forward-only move.” Apply this procedure: Verify both revisions exist, run –is-ancestor and perform the actual update with its own fast-forward protection. The expected mechanism is: The first command tests reachability; the second still enforces integration policy, so a stale check cannot replace the protected operation. For the school coding project, add one near-miss that exposes comparing commit hashes directly and rejecting legitimate descendants. The answer is complete only when it says why the near-miss fails and how the corrected model transfers to a different project without relying on the original variable names.
Case 4: CCA website. Transfer the rule using a feature branch rebased after the remote-tracking branch moved. State the input grain or object graph, the chapter boundary and the intended output before choosing syntax. Change only one variable, so a wrong prediction has a single plausible cause.
Reasoned route. Begin with “A deployment or update gate can require the current release to be an ancestor of the proposed tip before allowing a fast-forward-only move.” Apply this procedure: Verify both revisions exist, run –is-ancestor and perform the actual update with its own fast-forward protection. The expected mechanism is: The first command tests reachability; the second still enforces integration policy, so a stale check cannot replace the protected operation. For the CCA website, add one near-miss that exposes comparing commit hashes directly and rejecting legitimate descendants. The answer is complete only when it says why the near-miss fails and how the corrected model transfers to a different project without relying on the original variable names.
Diagnostic route
- Model check: ask the learner to draw or list the exact rows, fields, references, paths or states involved.
- Boundary check: create the smallest input that triggers comparing commit hashes directly and rejecting legitimate descendants.
- Evidence check: separate a printed value from identity, ordering, ownership, type or repository state.
- Repair check: use the reversible procedure “Verify both revisions exist, run –is-ancestor and perform the actual update with its own fast-forward protection.” and record the first changed observation.
- Transfer check: repeat the rule in a second context and identify what remains invariant.
A parent does not need to know the final Git merge-base syntax. For this chapter, useful prompts are: “What did you expect from Ancestor tests make safer fast-forward gates?”, “Which state changed first?”, “What evidence tests that prediction?”, and “Can the case exposing comparing commit hashes directly and rejecting legitimate descendants be made smaller?” The learner, not the parent, should supply the technical explanation.
Practice with an explained answer
Question. Build a tiny school coding project with main, report and experiment branches with ordinary divergence. Include one ordinary case, one boundary and one deliberate failure caused by comparing commit hashes directly and rejecting legitimate descendants. Predict each result before using a tool, then report the first point where observation differs from prediction.
Answer guide. A strong response starts with the rule: A deployment or update gate can require the current release to be an ancestor of the proposed tip before allowing a fast-forward-only move. It shows a trace, not only a final value. The ordinary case should demonstrate “The first command tests reachability; the second still enforces integration policy, so a stale check cannot replace the protected operation.” The boundary must exercise the same mechanism at an edge, and the deliberate failure must be repaired with: Verify both revisions exist, run –is-ancestor and perform the actual update with its own fast-forward protection. Other data choices are valid when the evidence supports the same causal chain.
Decision and transfer
For Ancestor tests make safer fast-forward gates, separate the documented Git merge-base mechanism from the project policy. State exactly what the technical contract guarantees, then state the project choice about validation, ordering, ownership, performance or recovery. Test whether the same distinction survives one transfer case, and keep stateful experiments disposable and backed up.
Previous chapter . Contents . Next chapter
CHAPTER 13 OF 20 . Debug and verify
13. –independent removes tips reachable from other tips
The –independent mode prints a minimal subset of supplied commits such that each output is not reachable from another output. Treat that sentence as a testable model. A secure learner can point to the relevant input, name the operation, describe the resulting state and identify one observation that would prove the model incomplete.
The high-value mistake in this chapter is calling the output merge bases even though the mode returns selected tips rather than common ancestors. It matters because the output may look reasonable while the ownership, ordering, identity or safety rule is wrong. Label every input tip, test pairwise reachability and compare the surviving maximal tips with command output.
For the –independent removes tips reachable from other tips chapter on Git merge-base, use a two-column trace during a short Punggol home session. On the left, write the predicted state for this exact mechanism before the tool runs. On the right, record the observation that bears on calling the output merge bases even though the mode returns selected tips rather than common ancestors. Explain the earliest difference with one causal sentence, then repeat only the smallest changed case.
Core worked example
git merge-base --independent main feature-a feature-b archived-tipExplained result. Any supplied tip already reachable from another supplied tip is omitted, leaving the independent frontier of the input set. Check the boundary as well as the happy path: ask what happens with an empty input, a duplicate or tied value, an unsupported type, a missing path, a NULL, or a second reference to the same object. Only the relevant boundary should be kept; the list is a prompt for judgment, not a demand to force every case into every example.
Four purposeful transfer cases
Case 1: school coding project. Stress-test the rule using main, report and experiment branches with ordinary divergence. State the input grain or object graph, the chapter boundary and the intended output before choosing syntax. Change only one variable, so a wrong prediction has a single plausible cause.
Reasoned route. Begin with “The –independent mode prints a minimal subset of supplied commits such that each output is not reachable from another output.” Apply this procedure: Label every input tip, test pairwise reachability and compare the surviving maximal tips with command output. The expected mechanism is: Any supplied tip already reachable from another supplied tip is omitted, leaving the independent frontier of the input set. For the school coding project, add one near-miss that exposes calling the output merge bases even though the mode returns selected tips rather than common ancestors. The answer is complete only when it says why the near-miss fails and how the corrected model transfers to a different project without relying on the original variable names.
Case 2: CCA website. Explain the rule using a feature branch rebased after the remote-tracking branch moved. State the input grain or object graph, the chapter boundary and the intended output before choosing syntax. Change only one variable, so a wrong prediction has a single plausible cause.
Reasoned route. Begin with “The –independent mode prints a minimal subset of supplied commits such that each output is not reachable from another output.” Apply this procedure: Label every input tip, test pairwise reachability and compare the surviving maximal tips with command output. The expected mechanism is: Any supplied tip already reachable from another supplied tip is omitted, leaving the independent frontier of the input set. For the CCA website, add one near-miss that exposes calling the output merge bases even though the mode returns selected tips rather than common ancestors. The answer is complete only when it says why the near-miss fails and how the corrected model transfers to a different project without relying on the original variable names.
Case 3: group assignment. Transfer the rule using parallel merges that produce a criss-cross ancestry pattern. State the input grain or object graph, the chapter boundary and the intended output before choosing syntax. Change only one variable, so a wrong prediction has a single plausible cause.
Reasoned route. Begin with “The –independent mode prints a minimal subset of supplied commits such that each output is not reachable from another output.” Apply this procedure: Label every input tip, test pairwise reachability and compare the surviving maximal tips with command output. The expected mechanism is: Any supplied tip already reachable from another supplied tip is omitted, leaving the independent frontier of the input set. For the group assignment, add one near-miss that exposes calling the output merge bases even though the mode returns selected tips rather than common ancestors. The answer is complete only when it says why the near-miss fails and how the corrected model transfers to a different project without relying on the original variable names.
Case 4: documentation repo. Predict the rule using release, translation and correction branches compared before integration. State the input grain or object graph, the chapter boundary and the intended output before choosing syntax. Change only one variable, so a wrong prediction has a single plausible cause.
Reasoned route. Begin with “The –independent mode prints a minimal subset of supplied commits such that each output is not reachable from another output.” Apply this procedure: Label every input tip, test pairwise reachability and compare the surviving maximal tips with command output. The expected mechanism is: Any supplied tip already reachable from another supplied tip is omitted, leaving the independent frontier of the input set. For the documentation repo, add one near-miss that exposes calling the output merge bases even though the mode returns selected tips rather than common ancestors. The answer is complete only when it says why the near-miss fails and how the corrected model transfers to a different project without relying on the original variable names.
Diagnostic route
- Model check: ask the learner to draw or list the exact rows, fields, references, paths or states involved.
- Boundary check: create the smallest input that triggers calling the output merge bases even though the mode returns selected tips rather than common ancestors.
- Evidence check: separate a printed value from identity, ordering, ownership, type or repository state.
- Repair check: use the reversible procedure “Label every input tip, test pairwise reachability and compare the surviving maximal tips with command output.” and record the first changed observation.
- Transfer check: repeat the rule in a second context and identify what remains invariant.
A parent does not need to know the final Git merge-base syntax. For this chapter, useful prompts are: “What did you expect from –independent removes tips reachable from other tips?”, “Which state changed first?”, “What evidence tests that prediction?”, and “Can the case exposing calling the output merge bases even though the mode returns selected tips rather than common ancestors be made smaller?” The learner, not the parent, should supply the technical explanation.
Practice with an explained answer
Question. Build a tiny CCA website with a feature branch rebased after the remote-tracking branch moved. Include one ordinary case, one boundary and one deliberate failure caused by calling the output merge bases even though the mode returns selected tips rather than common ancestors. Predict each result before using a tool, then report the first point where observation differs from prediction.
Answer guide. A strong response starts with the rule: The –independent mode prints a minimal subset of supplied commits such that each output is not reachable from another output. It shows a trace, not only a final value. The ordinary case should demonstrate “Any supplied tip already reachable from another supplied tip is omitted, leaving the independent frontier of the input set.” The boundary must exercise the same mechanism at an edge, and the deliberate failure must be repaired with: Label every input tip, test pairwise reachability and compare the surviving maximal tips with command output. Other data choices are valid when the evidence supports the same causal chain.
Decision and transfer
For –independent removes tips reachable from other tips, separate the documented Git merge-base mechanism from the project policy. State exactly what the technical contract guarantees, then state the project choice about validation, ordering, ownership, performance or recovery. Test whether the same distinction survives one transfer case, and keep stateful experiments disposable and backed up.
Previous chapter . Contents . Next chapter
CHAPTER 14 OF 20 . Debug and verify
14. Ordinary merge-base and fork-point answer different questions
Ordinary mode uses the current commit graph, while –fork-point also consults old tips recorded in the reflog of the upstream reference to locate where a topic was based before upstream rewrites. Treat that sentence as a testable model. A secure learner can point to the relevant input, name the operation, describe the resulting state and identify one observation that would prove the model incomplete.
The high-value mistake in this chapter is using fork-point for every branch and assuming it is a more accurate synonym. It matters because the output may look reasonable while the ownership, ordering, identity or safety rule is wrong. Run both modes after a controlled upstream rebase and explain which evidence each mode is allowed to use.
For the Ordinary merge-base and fork-point answer different questions chapter on Git merge-base, use a two-column trace during a short Punggol home session. On the left, write the predicted state for this exact mechanism before the tool runs. On the right, record the observation that bears on using fork-point for every branch and assuming it is a more accurate synonym. Explain the earliest difference with one causal sentence, then repeat only the smallest changed case.
Core worked example
git merge-base origin/main topic
git merge-base --fork-point origin/main topicExplained result. The first answer follows current parent edges; the second may recover an earlier upstream tip from the reflog and therefore identify a later historical branching point. Check the boundary as well as the happy path: ask what happens with an empty input, a duplicate or tied value, an unsupported type, a missing path, a NULL, or a second reference to the same object. Only the relevant boundary should be kept; the list is a prompt for judgment, not a demand to force every case into every example.
Four purposeful transfer cases
Case 1: group assignment. Explain the rule using parallel merges that produce a criss-cross ancestry pattern. State the input grain or object graph, the chapter boundary and the intended output before choosing syntax. Change only one variable, so a wrong prediction has a single plausible cause.
Reasoned route. Begin with “Ordinary mode uses the current commit graph, while –fork-point also consults old tips recorded in the reflog of the upstream reference to locate where a topic was based before upstream rewrites.” Apply this procedure: Run both modes after a controlled upstream rebase and explain which evidence each mode is allowed to use. The expected mechanism is: The first answer follows current parent edges; the second may recover an earlier upstream tip from the reflog and therefore identify a later historical branching point. For the group assignment, add one near-miss that exposes using fork-point for every branch and assuming it is a more accurate synonym. The answer is complete only when it says why the near-miss fails and how the corrected model transfers to a different project without relying on the original variable names.
Case 2: documentation repo. Transfer the rule using release, translation and correction branches compared before integration. State the input grain or object graph, the chapter boundary and the intended output before choosing syntax. Change only one variable, so a wrong prediction has a single plausible cause.
Reasoned route. Begin with “Ordinary mode uses the current commit graph, while –fork-point also consults old tips recorded in the reflog of the upstream reference to locate where a topic was based before upstream rewrites.” Apply this procedure: Run both modes after a controlled upstream rebase and explain which evidence each mode is allowed to use. The expected mechanism is: The first answer follows current parent edges; the second may recover an earlier upstream tip from the reflog and therefore identify a later historical branching point. For the documentation repo, add one near-miss that exposes using fork-point for every branch and assuming it is a more accurate synonym. The answer is complete only when it says why the near-miss fails and how the corrected model transfers to a different project without relying on the original variable names.
Case 3: robotics project. Predict the rule using several topic tips reduced to independent work lines. State the input grain or object graph, the chapter boundary and the intended output before choosing syntax. Change only one variable, so a wrong prediction has a single plausible cause.
Reasoned route. Begin with “Ordinary mode uses the current commit graph, while –fork-point also consults old tips recorded in the reflog of the upstream reference to locate where a topic was based before upstream rewrites.” Apply this procedure: Run both modes after a controlled upstream rebase and explain which evidence each mode is allowed to use. The expected mechanism is: The first answer follows current parent edges; the second may recover an earlier upstream tip from the reflog and therefore identify a later historical branching point. For the robotics project, add one near-miss that exposes using fork-point for every branch and assuming it is a more accurate synonym. The answer is complete only when it says why the near-miss fails and how the corrected model transfers to a different project without relying on the original variable names.
Case 4: revision repository. Contrast the rule using shallow clone whose missing parents change what ancestry is visible. State the input grain or object graph, the chapter boundary and the intended output before choosing syntax. Change only one variable, so a wrong prediction has a single plausible cause.
Reasoned route. Begin with “Ordinary mode uses the current commit graph, while –fork-point also consults old tips recorded in the reflog of the upstream reference to locate where a topic was based before upstream rewrites.” Apply this procedure: Run both modes after a controlled upstream rebase and explain which evidence each mode is allowed to use. The expected mechanism is: The first answer follows current parent edges; the second may recover an earlier upstream tip from the reflog and therefore identify a later historical branching point. For the revision repository, add one near-miss that exposes using fork-point for every branch and assuming it is a more accurate synonym. The answer is complete only when it says why the near-miss fails and how the corrected model transfers to a different project without relying on the original variable names.
Diagnostic route
- Model check: ask the learner to draw or list the exact rows, fields, references, paths or states involved.
- Boundary check: create the smallest input that triggers using fork-point for every branch and assuming it is a more accurate synonym.
- Evidence check: separate a printed value from identity, ordering, ownership, type or repository state.
- Repair check: use the reversible procedure “Run both modes after a controlled upstream rebase and explain which evidence each mode is allowed to use.” and record the first changed observation.
- Transfer check: repeat the rule in a second context and identify what remains invariant.
A parent does not need to know the final Git merge-base syntax. For this chapter, useful prompts are: “What did you expect from Ordinary merge-base and fork-point answer different questions?”, “Which state changed first?”, “What evidence tests that prediction?”, and “Can the case exposing using fork-point for every branch and assuming it is a more accurate synonym be made smaller?” The learner, not the parent, should supply the technical explanation.
Practice with an explained answer
Question. Build a tiny group assignment with parallel merges that produce a criss-cross ancestry pattern. Include one ordinary case, one boundary and one deliberate failure caused by using fork-point for every branch and assuming it is a more accurate synonym. Predict each result before using a tool, then report the first point where observation differs from prediction.
Answer guide. A strong response starts with the rule: Ordinary mode uses the current commit graph, while –fork-point also consults old tips recorded in the reflog of the upstream reference to locate where a topic was based before upstream rewrites. It shows a trace, not only a final value. The ordinary case should demonstrate “The first answer follows current parent edges; the second may recover an earlier upstream tip from the reflog and therefore identify a later historical branching point.” The boundary must exercise the same mechanism at an edge, and the deliberate failure must be repaired with: Run both modes after a controlled upstream rebase and explain which evidence each mode is allowed to use. Other data choices are valid when the evidence supports the same causal chain.
Decision and transfer
For Ordinary merge-base and fork-point answer different questions, separate the documented Git merge-base mechanism from the project policy. State exactly what the technical contract guarantees, then state the project choice about validation, ordering, ownership, performance or recovery. Test whether the same distinction survives one transfer case, and keep stateful experiments disposable and backed up.
Previous chapter . Contents . Next chapter
Fork-point can only use old upstream tips still present in the relevant local reflog, so clones and reflog expiration can change availability. Treat that sentence as a testable model. A secure learner can point to the relevant input, name the operation, describe the resulting state and identify one observation that would prove the model incomplete.
The high-value mistake in this chapter is writing a deployment script that assumes another machine has the same reflog history. It matters because the output may look reasonable while the ownership, ordering, identity or safety rule is wrong. Inspect the exact remote-tracking reflog and specify a safe fallback when fork-point returns no commit.
For the –fork-point depends on local reflog evidence chapter on Git merge-base, use a two-column trace during a short Punggol home session. On the left, write the predicted state for this exact mechanism before the tool runs. On the right, record the observation that bears on writing a deployment script that assumes another machine has the same reflog history. Explain the earliest difference with one causal sentence, then repeat only the smallest changed case.
Core worked example
git reflog show --date=iso origin/main
git merge-base --fork-point origin/main topicExplained result. The displayed old tips are local evidence available to fork-point; their absence is not proof that the topic never forked there. Check the boundary as well as the happy path: ask what happens with an empty input, a duplicate or tied value, an unsupported type, a missing path, a NULL, or a second reference to the same object. Only the relevant boundary should be kept; the list is a prompt for judgment, not a demand to force every case into every example.
Four purposeful transfer cases
Case 1: robotics project. Transfer the rule using several topic tips reduced to independent work lines. State the input grain or object graph, the chapter boundary and the intended output before choosing syntax. Change only one variable, so a wrong prediction has a single plausible cause.
Reasoned route. Begin with “Fork-point can only use old upstream tips still present in the relevant local reflog, so clones and reflog expiration can change availability.” Apply this procedure: Inspect the exact remote-tracking reflog and specify a safe fallback when fork-point returns no commit. The expected mechanism is: The displayed old tips are local evidence available to fork-point; their absence is not proof that the topic never forked there. For the robotics project, add one near-miss that exposes writing a deployment script that assumes another machine has the same reflog history. The answer is complete only when it says why the near-miss fails and how the corrected model transfers to a different project without relying on the original variable names.
Case 2: revision repository. Predict the rule using shallow clone whose missing parents change what ancestry is visible. State the input grain or object graph, the chapter boundary and the intended output before choosing syntax. Change only one variable, so a wrong prediction has a single plausible cause.
Reasoned route. Begin with “Fork-point can only use old upstream tips still present in the relevant local reflog, so clones and reflog expiration can change availability.” Apply this procedure: Inspect the exact remote-tracking reflog and specify a safe fallback when fork-point returns no commit. The expected mechanism is: The displayed old tips are local evidence available to fork-point; their absence is not proof that the topic never forked there. For the revision repository, add one near-miss that exposes writing a deployment script that assumes another machine has the same reflog history. The answer is complete only when it says why the near-miss fails and how the corrected model transfers to a different project without relying on the original variable names.
Case 3: test laboratory. Contrast the rule using ordinary, ancestor, unrelated, criss-cross, reflog and expired-reflog histories. State the input grain or object graph, the chapter boundary and the intended output before choosing syntax. Change only one variable, so a wrong prediction has a single plausible cause.
Reasoned route. Begin with “Fork-point can only use old upstream tips still present in the relevant local reflog, so clones and reflog expiration can change availability.” Apply this procedure: Inspect the exact remote-tracking reflog and specify a safe fallback when fork-point returns no commit. The expected mechanism is: The displayed old tips are local evidence available to fork-point; their absence is not proof that the topic never forked there. For the test laboratory, add one near-miss that exposes writing a deployment script that assumes another machine has the same reflog history. The answer is complete only when it says why the near-miss fails and how the corrected model transfers to a different project without relying on the original variable names.
Case 4: design review. Stress-test the rule using merge-base compared with fork-point, three-dot diff and merge-tree inputs. State the input grain or object graph, the chapter boundary and the intended output before choosing syntax. Change only one variable, so a wrong prediction has a single plausible cause.
Reasoned route. Begin with “Fork-point can only use old upstream tips still present in the relevant local reflog, so clones and reflog expiration can change availability.” Apply this procedure: Inspect the exact remote-tracking reflog and specify a safe fallback when fork-point returns no commit. The expected mechanism is: The displayed old tips are local evidence available to fork-point; their absence is not proof that the topic never forked there. For the design review, add one near-miss that exposes writing a deployment script that assumes another machine has the same reflog history. The answer is complete only when it says why the near-miss fails and how the corrected model transfers to a different project without relying on the original variable names.
Diagnostic route
- Model check: ask the learner to draw or list the exact rows, fields, references, paths or states involved.
- Boundary check: create the smallest input that triggers writing a deployment script that assumes another machine has the same reflog history.
- Evidence check: separate a printed value from identity, ordering, ownership, type or repository state.
- Repair check: use the reversible procedure “Inspect the exact remote-tracking reflog and specify a safe fallback when fork-point returns no commit.” and record the first changed observation.
- Transfer check: repeat the rule in a second context and identify what remains invariant.
A parent does not need to know the final Git merge-base syntax. For this chapter, useful prompts are: “What did you expect from –fork-point depends on local reflog evidence?”, “Which state changed first?”, “What evidence tests that prediction?”, and “Can the case exposing writing a deployment script that assumes another machine has the same reflog history be made smaller?” The learner, not the parent, should supply the technical explanation.
Practice with an explained answer
Question. Build a tiny documentation repo with release, translation and correction branches compared before integration. Include one ordinary case, one boundary and one deliberate failure caused by writing a deployment script that assumes another machine has the same reflog history. Predict each result before using a tool, then report the first point where observation differs from prediction.
Answer guide. A strong response starts with the rule: Fork-point can only use old upstream tips still present in the relevant local reflog, so clones and reflog expiration can change availability. It shows a trace, not only a final value. The ordinary case should demonstrate “The displayed old tips are local evidence available to fork-point; their absence is not proof that the topic never forked there.” The boundary must exercise the same mechanism at an edge, and the deliberate failure must be repaired with: Inspect the exact remote-tracking reflog and specify a safe fallback when fork-point returns no commit. Other data choices are valid when the evidence supports the same causal chain.
Decision and transfer
For –fork-point depends on local reflog evidence, separate the documented Git merge-base mechanism from the project policy. State exactly what the technical contract guarantees, then state the project choice about validation, ordering, ownership, performance or recovery. Test whether the same distinction survives one transfer case, and keep stateful experiments disposable and backed up.
Previous chapter . Contents . Next chapter
CHAPTER 16 OF 20 . Debug and verify
16. Fork-point can fail rather than invent an answer
When the relevant former tip is not in the reflog or the topic did not fork from an upstream tip, –fork-point may produce no result, avoiding a misleading arbitrary point. Treat that sentence as a testable model. A secure learner can point to the relevant input, name the operation, describe the resulting state and identify one observation that would prove the model incomplete.
The high-value mistake in this chapter is falling back silently to HEAD~1 or the ordinary base and presenting it as the recovered fork. It matters because the output may look reasonable while the ownership, ordering, identity or safety rule is wrong. Treat empty output as an explicit branch in the workflow and ask whether current ancestry or historical intent is required.
For the Fork-point can fail rather than invent an answer chapter on Git merge-base, use a two-column trace during a short Punggol home session. On the left, write the predicted state for this exact mechanism before the tool runs. On the right, record the observation that bears on falling back silently to HEAD~1 or the ordinary base and presenting it as the recovered fork. Explain the earliest difference with one causal sentence, then repeat only the smallest changed case.
Core worked example
fork=$(git merge-base --fork-point origin/main topic) || {
echo 'fork point unavailable' >&2
exit 1
}Explained result. The script stops instead of relabelling a different graph result as the historical fork point. Check the boundary as well as the happy path: ask what happens with an empty input, a duplicate or tied value, an unsupported type, a missing path, a NULL, or a second reference to the same object. Only the relevant boundary should be kept; the list is a prompt for judgment, not a demand to force every case into every example.
Four purposeful transfer cases
Case 1: test laboratory. Predict the rule using ordinary, ancestor, unrelated, criss-cross, reflog and expired-reflog histories. State the input grain or object graph, the chapter boundary and the intended output before choosing syntax. Change only one variable, so a wrong prediction has a single plausible cause.
Reasoned route. Begin with “When the relevant former tip is not in the reflog or the topic did not fork from an upstream tip, –fork-point may produce no result, avoiding a misleading arbitrary point.” Apply this procedure: Treat empty output as an explicit branch in the workflow and ask whether current ancestry or historical intent is required. The expected mechanism is: The script stops instead of relabelling a different graph result as the historical fork point. For the test laboratory, add one near-miss that exposes falling back silently to HEAD~1 or the ordinary base and presenting it as the recovered fork. The answer is complete only when it says why the near-miss fails and how the corrected model transfers to a different project without relying on the original variable names.
Case 2: design review. Contrast the rule using merge-base compared with fork-point, three-dot diff and merge-tree inputs. State the input grain or object graph, the chapter boundary and the intended output before choosing syntax. Change only one variable, so a wrong prediction has a single plausible cause.
Reasoned route. Begin with “When the relevant former tip is not in the reflog or the topic did not fork from an upstream tip, –fork-point may produce no result, avoiding a misleading arbitrary point.” Apply this procedure: Treat empty output as an explicit branch in the workflow and ask whether current ancestry or historical intent is required. The expected mechanism is: The script stops instead of relabelling a different graph result as the historical fork point. For the design review, add one near-miss that exposes falling back silently to HEAD~1 or the ordinary base and presenting it as the recovered fork. The answer is complete only when it says why the near-miss fails and how the corrected model transfers to a different project without relying on the original variable names.
Case 3: school coding project. Stress-test the rule using main, report and experiment branches with ordinary divergence. State the input grain or object graph, the chapter boundary and the intended output before choosing syntax. Change only one variable, so a wrong prediction has a single plausible cause.
Reasoned route. Begin with “When the relevant former tip is not in the reflog or the topic did not fork from an upstream tip, –fork-point may produce no result, avoiding a misleading arbitrary point.” Apply this procedure: Treat empty output as an explicit branch in the workflow and ask whether current ancestry or historical intent is required. The expected mechanism is: The script stops instead of relabelling a different graph result as the historical fork point. For the school coding project, add one near-miss that exposes falling back silently to HEAD~1 or the ordinary base and presenting it as the recovered fork. The answer is complete only when it says why the near-miss fails and how the corrected model transfers to a different project without relying on the original variable names.
Case 4: CCA website. Explain the rule using a feature branch rebased after the remote-tracking branch moved. State the input grain or object graph, the chapter boundary and the intended output before choosing syntax. Change only one variable, so a wrong prediction has a single plausible cause.
Reasoned route. Begin with “When the relevant former tip is not in the reflog or the topic did not fork from an upstream tip, –fork-point may produce no result, avoiding a misleading arbitrary point.” Apply this procedure: Treat empty output as an explicit branch in the workflow and ask whether current ancestry or historical intent is required. The expected mechanism is: The script stops instead of relabelling a different graph result as the historical fork point. For the CCA website, add one near-miss that exposes falling back silently to HEAD~1 or the ordinary base and presenting it as the recovered fork. The answer is complete only when it says why the near-miss fails and how the corrected model transfers to a different project without relying on the original variable names.
Diagnostic route
- Model check: ask the learner to draw or list the exact rows, fields, references, paths or states involved.
- Boundary check: create the smallest input that triggers falling back silently to HEAD~1 or the ordinary base and presenting it as the recovered fork.
- Evidence check: separate a printed value from identity, ordering, ownership, type or repository state.
- Repair check: use the reversible procedure “Treat empty output as an explicit branch in the workflow and ask whether current ancestry or historical intent is required.” and record the first changed observation.
- Transfer check: repeat the rule in a second context and identify what remains invariant.
A parent does not need to know the final Git merge-base syntax. For this chapter, useful prompts are: “What did you expect from Fork-point can fail rather than invent an answer?”, “Which state changed first?”, “What evidence tests that prediction?”, and “Can the case exposing falling back silently to HEAD~1 or the ordinary base and presenting it as the recovered fork be made smaller?” The learner, not the parent, should supply the technical explanation.
Practice with an explained answer
Question. Build a tiny robotics project with several topic tips reduced to independent work lines. Include one ordinary case, one boundary and one deliberate failure caused by falling back silently to HEAD~1 or the ordinary base and presenting it as the recovered fork. Predict each result before using a tool, then report the first point where observation differs from prediction.
Answer guide. A strong response starts with the rule: When the relevant former tip is not in the reflog or the topic did not fork from an upstream tip, –fork-point may produce no result, avoiding a misleading arbitrary point. It shows a trace, not only a final value. The ordinary case should demonstrate “The script stops instead of relabelling a different graph result as the historical fork point.” The boundary must exercise the same mechanism at an edge, and the deliberate failure must be repaired with: Treat empty output as an explicit branch in the workflow and ask whether current ancestry or historical intent is required. Other data choices are valid when the evidence supports the same causal chain.
Decision and transfer
For Fork-point can fail rather than invent an answer, separate the documented Git merge-base mechanism from the project policy. State exactly what the technical contract guarantees, then state the project choice about validation, ordering, ownership, performance or recovery. Test whether the same distinction survives one transfer case, and keep stateful experiments disposable and backed up.
Previous chapter . Contents . Next chapter
Commits rooted in separate histories have no merge base unless the visible graph contains a connection between them. Treat that sentence as a testable model. A secure learner can point to the relevant input, name the operation, describe the resulting state and identify one observation that would prove the model incomplete.
The high-value mistake in this chapter is interpreting empty output as the empty-tree object or as the first commit from one side. It matters because the output may look reasonable while the ownership, ordering, identity or safety rule is wrong. Check status and output separately on a disposable repository containing two orphan roots.
For the Unrelated histories have no common ancestor chapter on Git merge-base, use a two-column trace during a short Punggol home session. On the left, write the predicted state for this exact mechanism before the tool runs. On the right, record the observation that bears on interpreting empty output as the empty-tree object or as the first commit from one side. Explain the earliest difference with one causal sentence, then repeat only the smallest changed case.
Core worked example
if base=$(git merge-base root-a root-b); then
echo "$base"
else
echo 'no merge base'
fiExplained result. The negative result means the visible commit graphs do not share an ancestor; no synthetic empty-tree commit is returned as a base. Check the boundary as well as the happy path: ask what happens with an empty input, a duplicate or tied value, an unsupported type, a missing path, a NULL, or a second reference to the same object. Only the relevant boundary should be kept; the list is a prompt for judgment, not a demand to force every case into every example.
Four purposeful transfer cases
Case 1: school coding project. Contrast the rule using main, report and experiment branches with ordinary divergence. State the input grain or object graph, the chapter boundary and the intended output before choosing syntax. Change only one variable, so a wrong prediction has a single plausible cause.
Reasoned route. Begin with “Commits rooted in separate histories have no merge base unless the visible graph contains a connection between them.” Apply this procedure: Check status and output separately on a disposable repository containing two orphan roots. The expected mechanism is: The negative result means the visible commit graphs do not share an ancestor; no synthetic empty-tree commit is returned as a base. For the school coding project, add one near-miss that exposes interpreting empty output as the empty-tree object or as the first commit from one side. The answer is complete only when it says why the near-miss fails and how the corrected model transfers to a different project without relying on the original variable names.
Case 2: CCA website. Stress-test the rule using a feature branch rebased after the remote-tracking branch moved. State the input grain or object graph, the chapter boundary and the intended output before choosing syntax. Change only one variable, so a wrong prediction has a single plausible cause.
Reasoned route. Begin with “Commits rooted in separate histories have no merge base unless the visible graph contains a connection between them.” Apply this procedure: Check status and output separately on a disposable repository containing two orphan roots. The expected mechanism is: The negative result means the visible commit graphs do not share an ancestor; no synthetic empty-tree commit is returned as a base. For the CCA website, add one near-miss that exposes interpreting empty output as the empty-tree object or as the first commit from one side. The answer is complete only when it says why the near-miss fails and how the corrected model transfers to a different project without relying on the original variable names.
Case 3: group assignment. Explain the rule using parallel merges that produce a criss-cross ancestry pattern. State the input grain or object graph, the chapter boundary and the intended output before choosing syntax. Change only one variable, so a wrong prediction has a single plausible cause.
Reasoned route. Begin with “Commits rooted in separate histories have no merge base unless the visible graph contains a connection between them.” Apply this procedure: Check status and output separately on a disposable repository containing two orphan roots. The expected mechanism is: The negative result means the visible commit graphs do not share an ancestor; no synthetic empty-tree commit is returned as a base. For the group assignment, add one near-miss that exposes interpreting empty output as the empty-tree object or as the first commit from one side. The answer is complete only when it says why the near-miss fails and how the corrected model transfers to a different project without relying on the original variable names.
Case 4: documentation repo. Transfer the rule using release, translation and correction branches compared before integration. State the input grain or object graph, the chapter boundary and the intended output before choosing syntax. Change only one variable, so a wrong prediction has a single plausible cause.
Reasoned route. Begin with “Commits rooted in separate histories have no merge base unless the visible graph contains a connection between them.” Apply this procedure: Check status and output separately on a disposable repository containing two orphan roots. The expected mechanism is: The negative result means the visible commit graphs do not share an ancestor; no synthetic empty-tree commit is returned as a base. For the documentation repo, add one near-miss that exposes interpreting empty output as the empty-tree object or as the first commit from one side. The answer is complete only when it says why the near-miss fails and how the corrected model transfers to a different project without relying on the original variable names.
Diagnostic route
- Model check: ask the learner to draw or list the exact rows, fields, references, paths or states involved.
- Boundary check: create the smallest input that triggers interpreting empty output as the empty-tree object or as the first commit from one side.
- Evidence check: separate a printed value from identity, ordering, ownership, type or repository state.
- Repair check: use the reversible procedure “Check status and output separately on a disposable repository containing two orphan roots.” and record the first changed observation.
- Transfer check: repeat the rule in a second context and identify what remains invariant.
A parent does not need to know the final Git merge-base syntax. For this chapter, useful prompts are: “What did you expect from Unrelated histories have no common ancestor?”, “Which state changed first?”, “What evidence tests that prediction?”, and “Can the case exposing interpreting empty output as the empty-tree object or as the first commit from one side be made smaller?” The learner, not the parent, should supply the technical explanation.
Practice with an explained answer
Question. Build a tiny revision repository with shallow clone whose missing parents change what ancestry is visible. Include one ordinary case, one boundary and one deliberate failure caused by interpreting empty output as the empty-tree object or as the first commit from one side. Predict each result before using a tool, then report the first point where observation differs from prediction.
Answer guide. A strong response starts with the rule: Commits rooted in separate histories have no merge base unless the visible graph contains a connection between them. It shows a trace, not only a final value. The ordinary case should demonstrate “The negative result means the visible commit graphs do not share an ancestor; no synthetic empty-tree commit is returned as a base.” The boundary must exercise the same mechanism at an edge, and the deliberate failure must be repaired with: Check status and output separately on a disposable repository containing two orphan roots. Other data choices are valid when the evidence supports the same causal chain.
Decision and transfer
For Unrelated histories have no common ancestor, separate the documented Git merge-base mechanism from the project policy. State exactly what the technical contract guarantees, then state the project choice about validation, ordering, ownership, performance or recovery. Test whether the same distinction survives one transfer case, and keep stateful experiments disposable and backed up.
Previous chapter . Contents . Next chapter
A shallow clone intentionally omits parent history beyond recorded boundaries, so reachability and merge-base results can be absent or different until enough history is fetched. Treat that sentence as a testable model. A secure learner can point to the relevant input, name the operation, describe the resulting state and identify one observation that would prove the model incomplete.
The high-value mistake in this chapter is diagnosing remote branch corruption from a shallow client’s incomplete graph. It matters because the output may look reasonable while the ownership, ordering, identity or safety rule is wrong. Inspect .git/shallow, reproduce in a full clone and deepen only as much as the task requires.
For the Shallow history can hide the real base chapter on Git merge-base, use a two-column trace during a short Punggol home session. On the left, write the predicted state for this exact mechanism before the tool runs. On the right, record the observation that bears on diagnosing remote branch corruption from a shallow client’s incomplete graph. Explain the earliest difference with one causal sentence, then repeat only the smallest changed case.
Core worked example
git rev-parse --is-shallow-repository
git fetch --deepen=100 originExplained result. Deepening can reveal parent commits needed for the true common ancestry; the initial absence was evidence about local completeness, not necessarily the server graph. Check the boundary as well as the happy path: ask what happens with an empty input, a duplicate or tied value, an unsupported type, a missing path, a NULL, or a second reference to the same object. Only the relevant boundary should be kept; the list is a prompt for judgment, not a demand to force every case into every example.
Four purposeful transfer cases
Case 1: group assignment. Stress-test the rule using parallel merges that produce a criss-cross ancestry pattern. State the input grain or object graph, the chapter boundary and the intended output before choosing syntax. Change only one variable, so a wrong prediction has a single plausible cause.
Reasoned route. Begin with “A shallow clone intentionally omits parent history beyond recorded boundaries, so reachability and merge-base results can be absent or different until enough history is fetched.” Apply this procedure: Inspect .git/shallow, reproduce in a full clone and deepen only as much as the task requires. The expected mechanism is: Deepening can reveal parent commits needed for the true common ancestry; the initial absence was evidence about local completeness, not necessarily the server graph. For the group assignment, add one near-miss that exposes diagnosing remote branch corruption from a shallow client’s incomplete graph. The answer is complete only when it says why the near-miss fails and how the corrected model transfers to a different project without relying on the original variable names.
Case 2: documentation repo. Explain the rule using release, translation and correction branches compared before integration. State the input grain or object graph, the chapter boundary and the intended output before choosing syntax. Change only one variable, so a wrong prediction has a single plausible cause.
Reasoned route. Begin with “A shallow clone intentionally omits parent history beyond recorded boundaries, so reachability and merge-base results can be absent or different until enough history is fetched.” Apply this procedure: Inspect .git/shallow, reproduce in a full clone and deepen only as much as the task requires. The expected mechanism is: Deepening can reveal parent commits needed for the true common ancestry; the initial absence was evidence about local completeness, not necessarily the server graph. For the documentation repo, add one near-miss that exposes diagnosing remote branch corruption from a shallow client’s incomplete graph. The answer is complete only when it says why the near-miss fails and how the corrected model transfers to a different project without relying on the original variable names.
Case 3: robotics project. Transfer the rule using several topic tips reduced to independent work lines. State the input grain or object graph, the chapter boundary and the intended output before choosing syntax. Change only one variable, so a wrong prediction has a single plausible cause.
Reasoned route. Begin with “A shallow clone intentionally omits parent history beyond recorded boundaries, so reachability and merge-base results can be absent or different until enough history is fetched.” Apply this procedure: Inspect .git/shallow, reproduce in a full clone and deepen only as much as the task requires. The expected mechanism is: Deepening can reveal parent commits needed for the true common ancestry; the initial absence was evidence about local completeness, not necessarily the server graph. For the robotics project, add one near-miss that exposes diagnosing remote branch corruption from a shallow client’s incomplete graph. The answer is complete only when it says why the near-miss fails and how the corrected model transfers to a different project without relying on the original variable names.
Case 4: revision repository. Predict the rule using shallow clone whose missing parents change what ancestry is visible. State the input grain or object graph, the chapter boundary and the intended output before choosing syntax. Change only one variable, so a wrong prediction has a single plausible cause.
Reasoned route. Begin with “A shallow clone intentionally omits parent history beyond recorded boundaries, so reachability and merge-base results can be absent or different until enough history is fetched.” Apply this procedure: Inspect .git/shallow, reproduce in a full clone and deepen only as much as the task requires. The expected mechanism is: Deepening can reveal parent commits needed for the true common ancestry; the initial absence was evidence about local completeness, not necessarily the server graph. For the revision repository, add one near-miss that exposes diagnosing remote branch corruption from a shallow client’s incomplete graph. The answer is complete only when it says why the near-miss fails and how the corrected model transfers to a different project without relying on the original variable names.
Diagnostic route
- Model check: ask the learner to draw or list the exact rows, fields, references, paths or states involved.
- Boundary check: create the smallest input that triggers diagnosing remote branch corruption from a shallow client’s incomplete graph.
- Evidence check: separate a printed value from identity, ordering, ownership, type or repository state.
- Repair check: use the reversible procedure “Inspect .git/shallow, reproduce in a full clone and deepen only as much as the task requires.” and record the first changed observation.
- Transfer check: repeat the rule in a second context and identify what remains invariant.
A parent does not need to know the final Git merge-base syntax. For this chapter, useful prompts are: “What did you expect from Shallow history can hide the real base?”, “Which state changed first?”, “What evidence tests that prediction?”, and “Can the case exposing diagnosing remote branch corruption from a shallow client’s incomplete graph be made smaller?” The learner, not the parent, should supply the technical explanation.
Practice with an explained answer
Question. Build a tiny test laboratory with ordinary, ancestor, unrelated, criss-cross, reflog and expired-reflog histories. Include one ordinary case, one boundary and one deliberate failure caused by diagnosing remote branch corruption from a shallow client’s incomplete graph. Predict each result before using a tool, then report the first point where observation differs from prediction.
Answer guide. A strong response starts with the rule: A shallow clone intentionally omits parent history beyond recorded boundaries, so reachability and merge-base results can be absent or different until enough history is fetched. It shows a trace, not only a final value. The ordinary case should demonstrate “Deepening can reveal parent commits needed for the true common ancestry; the initial absence was evidence about local completeness, not necessarily the server graph.” The boundary must exercise the same mechanism at an edge, and the deliberate failure must be repaired with: Inspect .git/shallow, reproduce in a full clone and deepen only as much as the task requires. Other data choices are valid when the evidence supports the same causal chain.
Decision and transfer
For Shallow history can hide the real base, separate the documented Git merge-base mechanism from the project policy. State exactly what the technical contract guarantees, then state the project choice about validation, ordering, ownership, performance or recovery. Test whether the same distinction survives one transfer case, and keep stateful experiments disposable and backed up.
Previous chapter . Contents . Next chapter
CHAPTER 19 OF 20 . Transfer with judgment
19. Three-dot comparisons depend on merge-base semantics
A three-dot diff such as git diff A…B compares B with a merge base of A and B, so understanding base selection is essential before interpreting the patch. Treat that sentence as a testable model. A secure learner can point to the relevant input, name the operation, describe the resulting state and identify one observation that would prove the model incomplete.
The high-value mistake in this chapter is describing three dots as all changes on both branches or confusing diff syntax with revision-walk syntax. It matters because the output may look reasonable while the ownership, ordering, identity or safety rule is wrong. Compute the base explicitly, run the equivalent two-endpoint diff and handle multiple bases consciously.
For the Three-dot comparisons depend on merge-base semantics chapter on Git merge-base, use a two-column trace during a short Punggol home session. On the left, write the predicted state for this exact mechanism before the tool runs. On the right, record the observation that bears on describing three dots as all changes on both branches or confusing diff syntax with revision-walk syntax. Explain the earliest difference with one causal sentence, then repeat only the smallest changed case.
Core worked example
base=$(git merge-base A B)
git diff "$base" B
git diff A...BExplained result. For a unique base, the two diffs describe B’s changes since shared ancestry; the notation is not a symmetric union of both branch patches. Check the boundary as well as the happy path: ask what happens with an empty input, a duplicate or tied value, an unsupported type, a missing path, a NULL, or a second reference to the same object. Only the relevant boundary should be kept; the list is a prompt for judgment, not a demand to force every case into every example.
Four purposeful transfer cases
Case 1: robotics project. Explain the rule using several topic tips reduced to independent work lines. State the input grain or object graph, the chapter boundary and the intended output before choosing syntax. Change only one variable, so a wrong prediction has a single plausible cause.
Reasoned route. Begin with “A three-dot diff such as git diff A…B compares B with a merge base of A and B, so understanding base selection is essential before interpreting the patch.” Apply this procedure: Compute the base explicitly, run the equivalent two-endpoint diff and handle multiple bases consciously. The expected mechanism is: For a unique base, the two diffs describe B’s changes since shared ancestry; the notation is not a symmetric union of both branch patches. For the robotics project, add one near-miss that exposes describing three dots as all changes on both branches or confusing diff syntax with revision-walk syntax. The answer is complete only when it says why the near-miss fails and how the corrected model transfers to a different project without relying on the original variable names.
Case 2: revision repository. Transfer the rule using shallow clone whose missing parents change what ancestry is visible. State the input grain or object graph, the chapter boundary and the intended output before choosing syntax. Change only one variable, so a wrong prediction has a single plausible cause.
Reasoned route. Begin with “A three-dot diff such as git diff A…B compares B with a merge base of A and B, so understanding base selection is essential before interpreting the patch.” Apply this procedure: Compute the base explicitly, run the equivalent two-endpoint diff and handle multiple bases consciously. The expected mechanism is: For a unique base, the two diffs describe B’s changes since shared ancestry; the notation is not a symmetric union of both branch patches. For the revision repository, add one near-miss that exposes describing three dots as all changes on both branches or confusing diff syntax with revision-walk syntax. The answer is complete only when it says why the near-miss fails and how the corrected model transfers to a different project without relying on the original variable names.
Case 3: test laboratory. Predict the rule using ordinary, ancestor, unrelated, criss-cross, reflog and expired-reflog histories. State the input grain or object graph, the chapter boundary and the intended output before choosing syntax. Change only one variable, so a wrong prediction has a single plausible cause.
Reasoned route. Begin with “A three-dot diff such as git diff A…B compares B with a merge base of A and B, so understanding base selection is essential before interpreting the patch.” Apply this procedure: Compute the base explicitly, run the equivalent two-endpoint diff and handle multiple bases consciously. The expected mechanism is: For a unique base, the two diffs describe B’s changes since shared ancestry; the notation is not a symmetric union of both branch patches. For the test laboratory, add one near-miss that exposes describing three dots as all changes on both branches or confusing diff syntax with revision-walk syntax. The answer is complete only when it says why the near-miss fails and how the corrected model transfers to a different project without relying on the original variable names.
Case 4: design review. Contrast the rule using merge-base compared with fork-point, three-dot diff and merge-tree inputs. State the input grain or object graph, the chapter boundary and the intended output before choosing syntax. Change only one variable, so a wrong prediction has a single plausible cause.
Reasoned route. Begin with “A three-dot diff such as git diff A…B compares B with a merge base of A and B, so understanding base selection is essential before interpreting the patch.” Apply this procedure: Compute the base explicitly, run the equivalent two-endpoint diff and handle multiple bases consciously. The expected mechanism is: For a unique base, the two diffs describe B’s changes since shared ancestry; the notation is not a symmetric union of both branch patches. For the design review, add one near-miss that exposes describing three dots as all changes on both branches or confusing diff syntax with revision-walk syntax. The answer is complete only when it says why the near-miss fails and how the corrected model transfers to a different project without relying on the original variable names.
Diagnostic route
- Model check: ask the learner to draw or list the exact rows, fields, references, paths or states involved.
- Boundary check: create the smallest input that triggers describing three dots as all changes on both branches or confusing diff syntax with revision-walk syntax.
- Evidence check: separate a printed value from identity, ordering, ownership, type or repository state.
- Repair check: use the reversible procedure “Compute the base explicitly, run the equivalent two-endpoint diff and handle multiple bases consciously.” and record the first changed observation.
- Transfer check: repeat the rule in a second context and identify what remains invariant.
A parent does not need to know the final Git merge-base syntax. For this chapter, useful prompts are: “What did you expect from Three-dot comparisons depend on merge-base semantics?”, “Which state changed first?”, “What evidence tests that prediction?”, and “Can the case exposing describing three dots as all changes on both branches or confusing diff syntax with revision-walk syntax be made smaller?” The learner, not the parent, should supply the technical explanation.
Practice with an explained answer
Question. Build a tiny design review with merge-base compared with fork-point, three-dot diff and merge-tree inputs. Include one ordinary case, one boundary and one deliberate failure caused by describing three dots as all changes on both branches or confusing diff syntax with revision-walk syntax. Predict each result before using a tool, then report the first point where observation differs from prediction.
Answer guide. A strong response starts with the rule: A three-dot diff such as git diff A…B compares B with a merge base of A and B, so understanding base selection is essential before interpreting the patch. It shows a trace, not only a final value. The ordinary case should demonstrate “For a unique base, the two diffs describe B’s changes since shared ancestry; the notation is not a symmetric union of both branch patches.” The boundary must exercise the same mechanism at an edge, and the deliberate failure must be repaired with: Compute the base explicitly, run the equivalent two-endpoint diff and handle multiple bases consciously. Other data choices are valid when the evidence supports the same causal chain.
Decision and transfer
For Three-dot comparisons depend on merge-base semantics, separate the documented Git merge-base mechanism from the project policy. State exactly what the technical contract guarantees, then state the project choice about validation, ordering, ownership, performance or recovery. Test whether the same distinction survives one transfer case, and keep stateful experiments disposable and backed up.
Previous chapter . Contents . Next chapter
CHAPTER 20 OF 20 . Transfer with judgment
20. Robust automation validates revisions, cardinality and intent
Safe merge-base scripting checks revision existence, captures exit status, requests –all when uniqueness matters, and records whether it used graph ancestry or reflog-assisted intent. Treat that sentence as a testable model. A secure learner can point to the relevant input, name the operation, describe the resulting state and identify one observation that would prove the model incomplete.
The high-value mistake in this chapter is taking the first line of command substitution and using it in a destructive rebase without validation. It matters because the output may look reasonable while the ownership, ordering, identity or safety rule is wrong. Resolve commits with rev-parse, collect all bases, require the expected cardinality and preview the downstream operation.
For the Robust automation validates revisions, cardinality and intent chapter on Git merge-base, use a two-column trace during a short Punggol home session. On the left, write the predicted state for this exact mechanism before the tool runs. On the right, record the observation that bears on taking the first line of command substitution and using it in a destructive rebase without validation. Explain the earliest difference with one causal sentence, then repeat only the smallest changed case.
Core worked example
git rev-parse --verify A^{commit} B^{commit}
mapfile -t bases < <(git merge-base --all A B)
test "${#bases[@]}" -eq 1 || exit 2Explained result. The gate proceeds only when both names resolve to commits and current visible history yields exactly one best base; other graph shapes receive an explicit review path. Check the boundary as well as the happy path: ask what happens with an empty input, a duplicate or tied value, an unsupported type, a missing path, a NULL, or a second reference to the same object. Only the relevant boundary should be kept; the list is a prompt for judgment, not a demand to force every case into every example.
Four purposeful transfer cases
Case 1: test laboratory. Transfer the rule using ordinary, ancestor, unrelated, criss-cross, reflog and expired-reflog histories. State the input grain or object graph, the chapter boundary and the intended output before choosing syntax. Change only one variable, so a wrong prediction has a single plausible cause.
Reasoned route. Begin with “Safe merge-base scripting checks revision existence, captures exit status, requests –all when uniqueness matters, and records whether it used graph ancestry or reflog-assisted intent.” Apply this procedure: Resolve commits with rev-parse, collect all bases, require the expected cardinality and preview the downstream operation. The expected mechanism is: The gate proceeds only when both names resolve to commits and current visible history yields exactly one best base; other graph shapes receive an explicit review path. For the test laboratory, add one near-miss that exposes taking the first line of command substitution and using it in a destructive rebase without validation. The answer is complete only when it says why the near-miss fails and how the corrected model transfers to a different project without relying on the original variable names.
Case 2: design review. Predict the rule using merge-base compared with fork-point, three-dot diff and merge-tree inputs. State the input grain or object graph, the chapter boundary and the intended output before choosing syntax. Change only one variable, so a wrong prediction has a single plausible cause.
Reasoned route. Begin with “Safe merge-base scripting checks revision existence, captures exit status, requests –all when uniqueness matters, and records whether it used graph ancestry or reflog-assisted intent.” Apply this procedure: Resolve commits with rev-parse, collect all bases, require the expected cardinality and preview the downstream operation. The expected mechanism is: The gate proceeds only when both names resolve to commits and current visible history yields exactly one best base; other graph shapes receive an explicit review path. For the design review, add one near-miss that exposes taking the first line of command substitution and using it in a destructive rebase without validation. The answer is complete only when it says why the near-miss fails and how the corrected model transfers to a different project without relying on the original variable names.
Case 3: school coding project. Contrast the rule using main, report and experiment branches with ordinary divergence. State the input grain or object graph, the chapter boundary and the intended output before choosing syntax. Change only one variable, so a wrong prediction has a single plausible cause.
Reasoned route. Begin with “Safe merge-base scripting checks revision existence, captures exit status, requests –all when uniqueness matters, and records whether it used graph ancestry or reflog-assisted intent.” Apply this procedure: Resolve commits with rev-parse, collect all bases, require the expected cardinality and preview the downstream operation. The expected mechanism is: The gate proceeds only when both names resolve to commits and current visible history yields exactly one best base; other graph shapes receive an explicit review path. For the school coding project, add one near-miss that exposes taking the first line of command substitution and using it in a destructive rebase without validation. The answer is complete only when it says why the near-miss fails and how the corrected model transfers to a different project without relying on the original variable names.
Case 4: CCA website. Stress-test the rule using a feature branch rebased after the remote-tracking branch moved. State the input grain or object graph, the chapter boundary and the intended output before choosing syntax. Change only one variable, so a wrong prediction has a single plausible cause.
Reasoned route. Begin with “Safe merge-base scripting checks revision existence, captures exit status, requests –all when uniqueness matters, and records whether it used graph ancestry or reflog-assisted intent.” Apply this procedure: Resolve commits with rev-parse, collect all bases, require the expected cardinality and preview the downstream operation. The expected mechanism is: The gate proceeds only when both names resolve to commits and current visible history yields exactly one best base; other graph shapes receive an explicit review path. For the CCA website, add one near-miss that exposes taking the first line of command substitution and using it in a destructive rebase without validation. The answer is complete only when it says why the near-miss fails and how the corrected model transfers to a different project without relying on the original variable names.
Diagnostic route
- Model check: ask the learner to draw or list the exact rows, fields, references, paths or states involved.
- Boundary check: create the smallest input that triggers taking the first line of command substitution and using it in a destructive rebase without validation.
- Evidence check: separate a printed value from identity, ordering, ownership, type or repository state.
- Repair check: use the reversible procedure “Resolve commits with rev-parse, collect all bases, require the expected cardinality and preview the downstream operation.” and record the first changed observation.
- Transfer check: repeat the rule in a second context and identify what remains invariant.
A parent does not need to know the final Git merge-base syntax. For this chapter, useful prompts are: “What did you expect from Robust automation validates revisions, cardinality and intent?”, “Which state changed first?”, “What evidence tests that prediction?”, and “Can the case exposing taking the first line of command substitution and using it in a destructive rebase without validation be made smaller?” The learner, not the parent, should supply the technical explanation.
Practice with an explained answer
Question. Build a tiny school coding project with main, report and experiment branches with ordinary divergence. Include one ordinary case, one boundary and one deliberate failure caused by taking the first line of command substitution and using it in a destructive rebase without validation. Predict each result before using a tool, then report the first point where observation differs from prediction.
Answer guide. A strong response starts with the rule: Safe merge-base scripting checks revision existence, captures exit status, requests –all when uniqueness matters, and records whether it used graph ancestry or reflog-assisted intent. It shows a trace, not only a final value. The ordinary case should demonstrate “The gate proceeds only when both names resolve to commits and current visible history yields exactly one best base; other graph shapes receive an explicit review path.” The boundary must exercise the same mechanism at an edge, and the deliberate failure must be repaired with: Resolve commits with rev-parse, collect all bases, require the expected cardinality and preview the downstream operation. Other data choices are valid when the evidence supports the same causal chain.
Decision and transfer
For Robust automation validates revisions, cardinality and intent, separate the documented Git merge-base mechanism from the project policy. State exactly what the technical contract guarantees, then state the project choice about validation, ordering, ownership, performance or recovery. Test whether the same distinction survives one transfer case, and keep stateful experiments disposable and backed up.
Previous chapter . Contents . Next chapter
Parent guide: choose the next useful step
Start with evidence, not a label such as careless. Ask for one prediction and one trace. If the first transition is wrong, rebuild the model. If the model is sound but syntax fails, practise reference use. If routine cases are correct but boundaries fail, vary ties, defaults, unsupported inputs, ownership or missing paths. If explanations transfer, move to a small project.
Keep a weekly record with four lines: concept, prediction, observed difference and next test. Stop when fatigue replaces reasoning. A smaller case tomorrow is more useful than another hour of copying tonight.
Seek specialist help when cause and effect remain invisible after examples are reduced, when accessibility or data-loss implications are unclear, or when an important repository, database or application state may be at risk. Good support should make the learner’s reasoning more independent.
Capstone practice with explained routes
1. school coding project: model, boundary and recovery
Create a small school coding project using main, report and experiment branches with ordinary divergence. Combine “A merge base is a graph result” with one later chapter. Include an ordinary case, a boundary, a deliberate failure and a recovery. Write the expected state before each operation.
Explained route. Start with: git merge-base works on commit parent relationships and returns a best common ancestor, not the nearest timestamp, matching message or directory snapshot. Apply: Draw commits as nodes with arrows to parents, mark ancestors of both tips and remove any common ancestor dominated by a better one. Verify: The command prints the object name of a best common ancestor visible in the repository’s commit graph. Then add a second chapter whose boundary could change the outcome. A complete solution contains the input model, a trace, observed evidence, a correction and one transfer statement. The exact data may differ; the causal chain must be checkable.
2. CCA website: model, boundary and recovery
Create a small CCA website using a feature branch rebased after the remote-tracking branch moved. Combine “An ancestor tip can be its own merge base” with one later chapter. Include an ordinary case, a boundary, a deliberate failure and a recovery. Write the expected state before each operation.
Explained route. Start with: If A is an ancestor of B, the best common ancestor of A and B is A itself; no separate fork commit is required. Apply: Create a linear three-commit history and query the first and third commits. Verify: The output is HEAD~2 because a commit is reachable from itself and no later commit is an ancestor of the earlier tip. Then add a second chapter whose boundary could change the outcome. A complete solution contains the input model, a trace, observed evidence, a correction and one transfer statement. The exact data may differ; the causal chain must be checkable.
3. group assignment: model, boundary and recovery
Create a small group assignment using parallel merges that produce a criss-cross ancestry pattern. Combine “–all preserves every best answer” with one later chapter. Include an ordinary case, a boundary, a deliberate failure and a recovery. Write the expected state before each operation.
Explained route. Start with: Without –all, merge-base may output one best base when several exist; –all requests all merge bases. Apply: Run both forms on a rehearsed criss-cross repository and compare sets, not only the first line. Verify: The second command is the uniqueness test: one line confirms one visible best base, while several lines expose ambiguity the default form can hide. Then add a second chapter whose boundary could change the outcome. A complete solution contains the input model, a trace, observed evidence, a correction and one transfer statement. The exact data may differ; the causal chain must be checkable.
4. documentation repo: model, boundary and recovery
Create a small documentation repo using release, translation and correction branches compared before integration. Combine “–octopus finds bases for an n-way merge” with one later chapter. Include an ordinary case, a boundary, a deliberate failure and a recovery. Write the expected state before each operation.
Explained route. Start with: The –octopus mode computes best common ancestors of all supplied commits in preparation for an n-way merge. Apply: Draw the full graph and compare one –octopus call with several pairwise reductions. Verify: The output represents common ancestry for all three tips under octopus semantics rather than whichever pair happened to be reduced first. Then add a second chapter whose boundary could change the outcome. A complete solution contains the input model, a trace, observed evidence, a correction and one transfer statement. The exact data may differ; the causal chain must be checkable.
5. robotics project: model, boundary and recovery
Create a small robotics project using several topic tips reduced to independent work lines. Combine “–independent removes tips reachable from other tips” with one later chapter. Include an ordinary case, a boundary, a deliberate failure and a recovery. Write the expected state before each operation.
Explained route. Start with: The –independent mode prints a minimal subset of supplied commits such that each output is not reachable from another output. Apply: Label every input tip, test pairwise reachability and compare the surviving maximal tips with command output. Verify: Any supplied tip already reachable from another supplied tip is omitted, leaving the independent frontier of the input set. Then add a second chapter whose boundary could change the outcome. A complete solution contains the input model, a trace, observed evidence, a correction and one transfer statement. The exact data may differ; the causal chain must be checkable.
6. revision repository: model, boundary and recovery
Create a small revision repository using shallow clone whose missing parents change what ancestry is visible. Combine “Fork-point can fail rather than invent an answer” with one later chapter. Include an ordinary case, a boundary, a deliberate failure and a recovery. Write the expected state before each operation.
Explained route. Start with: When the relevant former tip is not in the reflog or the topic did not fork from an upstream tip, –fork-point may produce no result, avoiding a misleading arbitrary point. Apply: Treat empty output as an explicit branch in the workflow and ask whether current ancestry or historical intent is required. Verify: The script stops instead of relabelling a different graph result as the historical fork point. Then add a second chapter whose boundary could change the outcome. A complete solution contains the input model, a trace, observed evidence, a correction and one transfer statement. The exact data may differ; the causal chain must be checkable.
7. test laboratory: model, boundary and recovery
Create a small test laboratory using ordinary, ancestor, unrelated, criss-cross, reflog and expired-reflog histories. Combine “Three-dot comparisons depend on merge-base semantics” with one later chapter. Include an ordinary case, a boundary, a deliberate failure and a recovery. Write the expected state before each operation.
Explained route. Start with: A three-dot diff such as git diff A…B compares B with a merge base of A and B, so understanding base selection is essential before interpreting the patch. Apply: Compute the base explicitly, run the equivalent two-endpoint diff and handle multiple bases consciously. Verify: For a unique base, the two diffs describe B’s changes since shared ancestry; the notation is not a symmetric union of both branch patches. Then add a second chapter whose boundary could change the outcome. A complete solution contains the input model, a trace, observed evidence, a correction and one transfer statement. The exact data may differ; the causal chain must be checkable.
8. design review: model, boundary and recovery
Create a small design review using merge-base compared with fork-point, three-dot diff and merge-tree inputs. Combine “Common ancestor means reachable from both tips” with one later chapter. Include an ordinary case, a boundary, a deliberate failure and a recovery. Write the expected state before each operation.
Explained route. Start with: A commit is common to A and B when following zero or more parent edges from each tip can reach it. Apply: Use rev-list or log graph to trace parent reachability independently of file contents. Verify: The range can inspect commits on an ancestry path after the computed base; content similarity alone never creates a parent edge. Then add a second chapter whose boundary could change the outcome. A complete solution contains the input model, a trace, observed evidence, a correction and one transfer statement. The exact data may differ; the causal chain must be checkable.
Frequently asked questions
How long should a practice session be?
Use one complete prediction–observation–explanation cycle while attention remains good. Ten to twenty focused minutes can be enough.
Should every option or function be memorised?
No. Memorise the governing distinctions and practise retrieving the official reference. Understanding means predicting and explaining, not reciting a parameter list.
What if the result is correct but the explanation is weak?
Treat it as partial success. Ask for a trace and change one boundary. A reliable model survives controlled variation.
Is the shortest solution the best?
Not automatically. Prefer the solution whose semantics, failure modes and maintenance cost are easiest to justify for the actual project.
When should official documentation be used?
Use it whenever syntax, supported types, SQL dialect behaviour or Git version details matter. Primary documentation settles the current contract.
How can a parent help without technical expertise?
Ask what was predicted, where the first difference appeared, what evidence matters and which smaller example could isolate it.
How do we test transfer?
Change the context, vocabulary and one boundary. Require the learner to identify the invariant before using a tool.
What should be saved after practice?
Keep the corrected rule, one trace, one boundary case and the next question. Avoid storing pages of unexplained output.
Can these exercises replace backups?
No. Use disposable examples and proper backups. Learning should not endanger schoolwork, repositories or personal data.
What counts as mastery?
The learner can predict, verify, diagnose, recover and justify a choice across more than one context, while knowing when to consult the current reference.

