Skip to content
← Free FDE training guides

Free learning / Git 101 + 30-minute merge lab

Git 101: know which change you are handing over

Define the working tree, staging area, commit and branch. Run real Git in a disposable repository and see why a passing working-copy check can describe different bytes from the commit.

No account needed. Use your own copy for writing and keep the original as a reference.

Engineering lab library / Run locally

See which bytes the commit actually contains

Predict seven states, inspect both diffs, then change staging and file selection separately. Match the evidence to the exact snapshot you hand over.

Real Git commands run in a new temporary repository that is removed after capture. No remote, model or network; your existing repository and global Git configuration are unchanged.

Search titles, outcomes and prerequisites, then narrow by runtime.

2 of 2 labs · All labs

  1. Start here / Python 3.11+ · Standard library

    Git snapshot and evidence lab · Python

    Compare seven actual Git states, restage one edit and inspect an unrelated path added to the commit.

    Python 3.11+ and Git 2.28+ · No account or network

  2. Python 3.11+ · Standard library

    Git merge and behavior lab · Python

    Observe a clean but broken merge, repair its caller against the same contract and inspect a real text conflict before abort.

    Python 3.11+ and Git 2.28+ · Temporary local repositories · No network

An original 40-minute introduction for someone who can reason about software but is new to Git. Follow one fictional configuration change through the files you edit, the snapshot you select and the history you record. Then run real Git commands through a small, disposable local lab.

An optional 30-minute extension below combines two real branches, catches a broken caller after a clean merge, and inspects a separate text conflict.

Want to see the three versions before opening a terminal? Start with the visual Git introduction and interactive snapshot exercise, then return here to reproduce the sequence with real Git.

1. Name the pieces before using the commands

Git is a distributed version-control tool. It records project snapshots and their relationships so people can compare changes and collaborate. It is not a programming language, a coding agent or a hosting website. GitHub and other hosting services can store Git repositories and add review workflows. A local Git commit does not require a hosting account.

A repository holds the project's Git history and metadata. In the ordinary checkout used here, that metadata lives in .git; the editable project files around it form the working tree. A downloaded archive of code may have no Git history. Having a folder of files and having a repository are different.

The index, often called the staging area, holds the proposed next snapshot. Think of preparing a package for a teammate: editing changes your desk copy; staging selects bytes for the package; committing records the selected snapshot. The analogy has limits: staging is not approval, and a commit is neither a deployment nor proof that the code works. Git stores more than a folder copy, including parent relationships and author/message metadata.

A commit ID identifies a particular recorded commit. A branch is a named reference to a commit that normally advances when you commit on it. HEAD normally identifies your checked-out branch, although Git can also check out a commit directly. A branch is not a second folder or a backup of uncommitted work.

For an FDE using Claude Code or another coding agent, these distinctions answer a practical question: “Which exact change am I asking someone to accept?” The agent may edit files; Git records selected content. Neither substitutes for your review of scope, behavior and customer requirements.

2. Read the three versions of one file

The fictional file policy.json contains one setting, max_items. The lab records 1, stages 2, then edits the working copy to 3. At that moment there are three versions worth inspecting: committed 1, staged 2 and working 3.

Read-only commandComparison or evidenceWhat it cannot establish
git status --shortStaged, unstaged and untracked pathsWhether a change is correct
git diff -- policy.jsonWorking file against the indexThe complete next commit
git diff --cached -- policy.jsonIndex against HEADLater unstaged edits
git show HEAD:policy.jsonContent recorded in the current commitThe current file on your desk

git add -- policy.json copies that file's current content into the index. It does not keep following future edits. An ordinary git commit -m ... records the index; the lab deliberately avoids options that select content differently. -- ends command options and makes the following item a path.

For the tracked file in this exercise, the two leading status columns compare index to HEAD, then working file to index. A space followed by M ( M) means an unstaged modification; M followed by a space (M ) means a staged modification; MM means both comparisons changed. ?? marks an untracked file. Preserve the spaces when reading the printed strings. The merge extension below introduces the additional index stages for conflicts.

The second file, note.txt, is an unrelated fictional note. The ordinary diff above does not display its untracked contents. Read status and inspect the intended paths; an empty diff does not mean there are no files left to consider.

UNDERSTAND THE SYSTEM

Which version are you handing over?

Follow one fictional policy.json change through actual Git states. The diagram explains the local lab; it does not edit your files. Values show max_items in each version.

FOLLOW THE WORK

Watch one example, step by step.

7 authored stepsYou control the pace
01 / EXPLORE THE PARTSControls loading · written explanations below
Direction of information or workReturn / feedback

WHAT THIS PART DOES

Working tree

The editable file on disk. An editor or coding agent changes these bytes; Git does not automatically commit them.

CONNECTED TO
  • git add: Index / staging area
  • Check these bytes: Working-copy check
Read the full worked example
  1. 01
    Start with one recorded version

    The temporary repository records max_items = 1. The working file, index and commit agree. No application behavior has been tested.

    BASELINE: Working 1 · index 1 · committed 1

  2. 02
    Edit the working file

    The editor changes the value to 2 and creates an unrelated note. The index and commit still contain 1. Status shows an unstaged policy and an untracked note.

    EDITED: Working 2 · index 1 · committed 1

  3. 03
    Select a snapshot

    git add -- policy.json stages value 2. It leaves the unrelated note out. The next ordinary commit would record 2; the current commit still contains 1.

    STAGED: Working 2 · index 2 · committed 1

  4. 04
    Edit again after staging

    The working file changes to 3. The index keeps 2, so policy.json has staged and unstaged changes at once. Staging is not a live subscription to the file.

    EDITED-AFTER-STAGE: Working 3 · index 2 · committed 1

  5. 05
    Read both comparisons

    git diff compares working 3 with index 2. git diff --cached compares index 2 with committed 1. Each command answers a different review question.

    REVIEW: Unstaged: 2 → 3 · staged: 1 → 2

  6. 06
    Commit and check the mismatch

    The ordinary commit records staged value 2. The working copy still has 3. Its simple equals-3 check passes, while the same check against the committed file fails.

    COMMITTED: Working check: true · committed check: false

  7. 07
    Name the earlier snapshot

    review/baseline points to the first commit, where the value was 1. Creating that reference did not switch the checkout or capture its uncommitted value 3. There is no remote.

    BRANCH-REFERENCE: main: new commit · review/baseline: first commit

Read the connections in plain English
  1. 01
    Working tree → Index / staging area

    Copy the selected file's current bytes into the index.

  2. 02
    Index / staging area → Recorded commit

    Record the current index in a new local commit.

  3. 03
    Working tree → Working-copy check

    The fixture check reads the working file, not Git history.

  4. 04
    Working-copy check → Handoff evidence

    A passing result is useful only for the content it actually checked.

  5. 05
    Recorded commit → Handoff evidence

    Read the committed file and compare it with the checked candidate.

Check your understanding: An agent says the working-copy check passed. Does that prove the commit contains the checked change?

No. Inspect the selected and committed bytes. In the default lab, the working file contains 3 but the commit contains 2. Match test evidence to the exact candidate; a Git snapshot alone proves no application behavior.

3. Predict and run the local history

Download fde-git-snapshot-lab.py. Use Python 3.11+ and an approved Git 2.28+ installation. No Python packages, account, model, credentials or internet are needed to execute it. Run these commands from any ordinary working folder:

Code example
python3 --version
git --version
python3 fde-git-snapshot-lab.py

The program creates a new temporary repository and runs real Git commands only there. It uses a fictional author, ignores inherited Git repository/configuration overrides and uses an empty initialization template. It does not change your global Git configuration or the directory from which you launched it. The temporary repository is removed after the report is captured. The report includes the actual diff text and commit IDs; IDs may differ between runs.

Predict each event before comparing its JSON output. working, index and committed report actual file contents, not hardcoded expected answers.

EventWorking / index / committed max_itemsObservation
baseline1 / 1 / 1One recorded file; clean status
edited2 / 1 / 1Policy unstaged; note untracked
staged2 / 2 / 1Policy staged; note still untracked
edited-after-stage3 / 2 / 1Policy status is MM
review3 / 2 / 1The two diffs compare different changes
committed3 / 2 / 2Commit contains 2; working edit to 3 remains
branch-reference3 / 2 / 2New reference points to baseline 1; checkout stays on main

In committed, one small fixture check asks whether max_items equals 3. The working file passes; the committed file does not. This is an actual value comparison, not an application test suite or a quality score. It exposes a common handoff problem: evidence from one set of bytes can be attached to another.

The final command creates review/baseline at the first commit. It does not switch branches, copy the current working edits or merge anything. There are no remotes. Nothing is pushed, published or deployed.

4. Change one decision and inspect the result

Make two separate copies of the Python file and keep the original for comparison.

Experiment A — stage the later edit. In one copy, set RESTAGE_AFTER_EDIT = True. The review now shows 3 in the working tree and index. The next commit records 3, the policy diff becomes empty, and the unrelated note remains untracked. Both fixture checks pass. Explain why this is an evidence match, not proof that a limit of 3 is a good product decision.

Experiment B — include another path. In a fresh copy, set INCLUDE_NOTE = True and leave restaging false. The next commit now contains note.txt as well as policy.json; the policy mismatch remains. The note is harmless fictional text, but its inclusion illustrates a scope error. In a real repository, inspect all staged paths and bytes for unrelated work and sensitive material before committing or publishing. A tracked secret is not removed from history merely by deleting its current file.

For each experiment, keep the changed setting, actual status, committed tree and your explanation. Do not substitute a screenshot of a green process exit for the contents you intend to hand over.

4a. Merge two good changes and inspect the combination

Two people start from the same project version. One renames a function and updates the existing caller. The other adds a batch caller using the old name. Each sees working behavior on their own branch. What happens when you put their work together?

A common ancestor is a commit shared by both histories. A merge combines work from those histories into your checked-out branch. A parent is a previous commit referenced by a later commit. In this lab the branches have diverged, so Git creates a merge commit with two parents. In a different history, a fast-forward can simply advance a branch reference; not every merge command creates a new commit.

Download fde-git-merge-lab.py beside the first lab. Use Python 3.11+ and Git 2.28+. It creates two new temporary repositories with a fictional author, empty hooks and initialization templates, and isolated Git configuration. It runs real Git commands and small Python behavioral checks only inside its disposable work. No account, model, package installation, remote or network is involved.

Code example
python3 --version
git --version
python3 fde-git-merge-lab.py

The outer program prints an experiment report. Its successful exit means the experiment completed, not that every child command passed. Read the nested exit_code, scope, observations and commit identities. Temporary repositories are removed after the evidence is captured; cleanup is reported separately.

Predict the first repository

The fictional application wraps text in brackets. An entry point is a callable way into it: render one label or render a batch. The probe is a small Python program that calls those entry points and compares their outputs with independent expected values. The API here is a Python function interface, not an HTTP endpoint.

ObservationGit history or filesActual behavioral scope
baselineformat_label and its existing callerExisting entry point passes
rename_branchRename to render_label; update the existing callerExisting entry point passes; batch is absent
add_batch_branchAdd a batch caller using format_label from the original baseExisting and batch entry points pass
mergeCombine both histories; Git returns 0 with two parentsContent integrated; behavior not established by that exit
broken_probeNew implementation plus an old-name batch importExisting passes; batch fails with ImportError
repairChange only the batch import to the renamed APIThe unchanged combined contract passes before and after commit

Inspect clean_merge.merge.parents and observed_merge_base. The first parent is the checked-out rename branch; the other is the incoming batch branch. The base matches the original commit. This is observed ancestry, not a claim inferred from similar filenames. The small graph below abbreviates IDs so you can follow it; use the actual report when naming a candidate.

The clean merge has no unresolved index entries. That does not stop batch.py from importing a function that no longer exists. The two changes touched compatible file locations, but their application contracts did not compose. Configured hooks can run checks in other repositories; this exercise explicitly uses empty hooks. The lesson is that a successful content integration alone does not establish correct behavior.

Repair the caller while protecting the measurement

The independent probe is authored in the lab program, outside the Git repositories. Merging cannot edit its expected values. Compare probe_sha256 across the broken and repaired combined runs: it stays the same, as does the existing, batch scope. The repair changes only this import:

Code example
# Before: a name removed by the other branch
from label_api import format_label

# After: use the renamed implementation, preserving the local alias
from label_api import render_label as format_label

Do not confuse the passing working-copy repair with the still-broken HEAD. The dirty working_probe reports head_commit and head_tree separately; tested_commit and tested_tree are null because its checked bytes are not yet that recorded snapshot. Its tested_working_files digests identify the bytes read. After staging and committing, the committed probe is clean and identifies the repair commit/tree. The report compares staged/committed tree IDs and the actual tracked-file digests before declaring tree_matches_tested_snapshot true.

In a separate copy of the lab, set REPAIR_AFTER_MERGE = False. Predict the Git exit and combined probe exit before running it. The merge still succeeds, the behavioral probe still fails, and no repair commit is produced. The report does not turn a missing repair into a passing result. Keep the original and changed reports; explain which observation changed and which did not.

Compare a real text conflict and a controlled abort

The second repository changes the same decision.txt line to different values on two branches. Here Git cannot complete the ordinary merge automatically:

EvidenceWhat to inspect
Merge commandNonzero exit_code and a conflict message
Recorded historyhead_unchanged is true; no completed merge commit
Indexunmerged_stages: 1 is the base, 2 is the checked-out side, 3 is the incoming side
Working file<<<<<<<, ======= and >>>>>>> markers separate competing content
Abortgit merge --abort returns to the captured clean pre-merge state

“Ours” and “theirs” describe roles in this merge, not permanent ownership or a judgment about which requirement is correct. Blindly keeping a side may remove needed work. In real integration, resolve the intended behavior, stage the reviewed resolution and test it. This lab instead records the conflict and demonstrates abandoning it from a known clean start. Abort attempts restoration; it cannot promise to reconstruct arbitrary edits that existed before a merge. Preserve unrelated work before attempting integration.

UNDERSTAND THE SYSTEM

A clean merge can still break the application.

Two developers start from the same recorded version. One renames a function; the other adds a caller using its old name. Follow actual Git ancestry into the combined snapshot, then inspect the separate Python behavior check. Short labels stand for the real commit IDs in your downloaded lab report.

FOLLOW THE WORK

Watch one example, step by step.

4 authored stepsYou control the pace
01 / EXPLORE THE PARTSControls loading · written explanations below
Parent → child commits; final link → behavioral evidenceReturn / feedback

WHAT THIS PART DOES

Common ancestor

Both branches start at this commit. It contains the original function and its existing caller. The new batch entry point does not exist yet.

CONNECTED TO
  • Rename: Rename branch
  • Add caller: New-caller branch
Read the full worked example
  1. 01
    Check each branch

    The rename branch checks its existing entry point. The new-caller branch checks both entry points against its own old API. These are truthful passing observations of different snapshots and scopes. They do not establish that the later combination works.

    PARENT EVIDENCE: Rename: existing only · new caller: both pass

  2. 02
    Merge without conflict

    Git records a two-parent merge and returns success. The new caller was added in another file, so the rename causes no textual conflict. Inspect the merged files: the implementation exports the new name while the added caller still imports the old one. Hooks are empty in this controlled repository; configured hooks elsewhere may run checks.

    CONTENT INTEGRATION: Git exit 0 · two parents · behavior untested

  3. 03
    Run the combined contract

    The independent Python probe now tries both entry points in the merged tree. The existing caller works, but the batch caller fails to import the removed name. Keep Git's successful merge and the failing behavior result together; one does not cancel the other.

    OBSERVED FAILURE: Merge succeeded · combined probe failed

  4. 04
    Repair and recheck

    Change only the new caller to use the renamed function. The unchanged combined contract now passes. The lab records a separate repair commit after the merge and compares the tested tree with the recorded tree. That repair commit is not drawn here: the two parent arrows still describe the original merge.

    REPAIRED DESCENDANT: Same contract passes · tested tree recorded

Read the connections in plain English
  1. 01
    Common ancestor → Rename branch

    Create the function-rename commit from the common ancestor.

  2. 02
    Common ancestor → New-caller branch

    Create a different commit from that same ancestor; this is divergent work.

  3. 03
    Rename branch → Merged snapshot

    The checked-out rename branch becomes the merge's first parent.

  4. 04
    New-caller branch → Merged snapshot

    The new-caller branch becomes the merge's other parent.

  5. 05
    Merged snapshot → Behavioral check

    This link means behavioral evidence, not commit ancestry. Inspect the combined tree independently.

Check your understanding: Both developers had passing checks. Why is the merged candidate still broken?

The checks described different snapshots and entry points. The added caller depends on a function removed by the other branch. Git combined their file changes without a text conflict; the independent combined contract exposes the incompatible API. Recheck the resulting candidate rather than treating either parent's evidence as evidence of the merge.

5. Carry this into an agent-assisted change

A fictional client asks for one bounded policy change. An assistant edits the policy and writes a planning note. Before accepting its proposed commit:

  1. Confirm the intended repository and current branch. Read status before edits so you can distinguish existing work from the agent's contribution.
  2. Review the changed behavior and its requirement. Inspect working and staged differences, including relevant untracked paths. Do not sweep unrelated files into a commit to make the status look clean.
  3. Select the intended content deliberately. If the file changes after staging, review the new content before staging it again.
  4. Associate test evidence with the exact candidate contents and commit. A clean checkout of that commit is one way to verify the handoff independently; the snapshot exercise's value check is not your application's test suite.
  5. Treat remote publication and deployment as separate authorized operations. A pull request is a hosting-service review mechanism, not a Git commit.

You do not need a clever command sequence to explain this. Say which bytes were changed, which were recorded, what evidence covers those bytes and what remains outside the handoff. The Claude Code setup lesson applies that habit to the offline ticket-triage project. The supplied project intentionally starts with failing tests; this introduction does not erase them.

6. Keep your evidence and continue

Before moving on, explain why the default run can have a successful working-copy check and a different committed value. Draw the working tree, index and commit, then label the two comparisons made by the diff commands. Ask a teammate to identify the intended snapshot without watching your terminal session.

For the merge extension, also hand over the two parent scopes, common ancestor, combined failure, one-line repair and unchanged contract hash. Have the receiving engineer explain why the dirty passing result does not belong to the old HEAD, and why a textual conflict is a different observation from a broken clean merge. These exercises establish local fixture behavior, not production release safety.

Continue to the client delivery workbook to connect technical evidence to a request, owner and acceptance decision. If the terminal itself is unfamiliar, start with your first command.

Primary references checked 21 October 2026. This explanation, fictional example and program are original LockedIn Labs instruction.

Merge references checked 25 October 2026:

Before you move on

Keep the evidence of your work.

  • A sketch of the working tree, index and recorded commit.
  • Actual diffs and both changed-copy experiment results.
  • A combined behavior check, exact repair evidence and a clean-start conflict/abort report.

Keep these in your own working copy. Reading this page does not save work or record completion.

Suggested next free session

Tests 101: understand what a green result means

Understand what a test result establishes about the selected code. This is a suggested sequence; choose the practice that addresses your current gap.

Open the next free guide

Free account

Give your practice a home.

Try a role exercise with account drafts and a downloadable worksheet. Keep the files you made in this guide in your own working copy.

Create a free learning account

Guided training · by application

Build toward a program.

Request structured lessons and a training seat. Scope, schedule, feedback arrangements and tuition are confirmed in writing before you commit.

Explore a training application
Have Academy access?

Use your existing training seat to open worked explanations and practice in the related lesson. Creating a free account does not grant a seat.

Open the related Academy lesson →
Back to top ↑