Skip to main content

Git Fundamentals: Worked Examples

Work through each trace before reading the explanation. Then solve the transfer task without the page open.

Example 1: What gets committed?​

Commit a file containing A. Change it to B and stage it. Change the working file to C without staging again. The next commit contains B, while the working tree still contains C.

The wrong prediction, “commit saves everything currently visible,” confuses the index with the working tree. Compare staged and unstaged diffs before committing. Their difference explains both deliberate partial commits and accidental omissions.

Example 2: Reverse a published mistake​

History is A -> B -> C, and B introduced faulty configuration. Reverting B creates a new commit applying its inverse while preserving shared history.

If C changed the same lines, resolve the conflict according to desired current behavior. Even a conflict-free inverse can break C's assumptions: C may call a function introduced by B. A clean patch is not evidence of a working program; rerun the relevant behavior check.

Transfer and self-check​

B adds a function; C calls it. What must you check after reverting B? Check: the call must be removed, adapted, or supplied by a valid replacement, even if Git reports no conflict.

Evidence to keep​

Save your first attempt, corrected reasoning, and transfer result as checkpoint evidence. A matching final answer without an explanation is insufficient. Continue with the guided lab and use the reading guide to repair a specific gap.