DevOps engineer comparing Git configuration origins and linked worktree paths on two monitors

Git includeIf: Validate Path Matching Across Linked Worktrees

Wed, Dec 2, 2026

Consider a proposed fixture in which a linked checkout physically inside a team-owned directory receives fallback, while another linked checkout physically outside that directory receives team. Nothing in that observation, by itself, proves Git has misbehaved. A gitdir: condition can be operating exactly as documented while expressing the wrong policy: it matches an administrative Git directory, not necessarily the directory containing the checked-out files. Git 2.56 adds a worktree: conditional form intended to match the worktree location instead. Git’s 2.56 release notes describe worktree-location conditional inclusion as a new addition, while the 2.56.1 git-config manual defines the matching semantics used in this playbook.

The operational question is therefore not merely “did includeIf match?” It is three questions kept deliberately separate: did the selector follow its documented input, did the resulting value come from the expected configuration file, and does the resulting four-checkout mapping satisfy the independently declared physical-location policy?

The laboratory below is proposed and was not executed during this research. Every result is therefore a documented expectation, never a captured observation. The fixture stays local, uses no remotes, credentials, hooks, submodules or sparse-checkout behavior, and queries one inert setting: lab.includeproof. A real run must record its own executable path, Git version, helper-runtime version, paths, configuration bytes, origins, statuses and raw output before any adoption decision is made.

Write the checkout-location contract

Start with the policy before choosing Git syntax:

Any checkout whose physical checkout root is beneath <LAB>/zone/team/ must receive lab.includeproof=team. Every other checkout must receive lab.includeproof=fallback.

<LAB> means one absolute, canonical directory owned for this disposable experiment. The proposed environment is POSIX/Linux on a case-sensitive filesystem. The target baseline is Git 2.56.1, but that version is a laboratory choice, not an assertion about whatever git happens to resolve from PATH.

The inert key has only two permitted values:

lab.includeproof = fallback
lab.includeproof = team

It deliberately does not affect identities, authentication, network activity, hooks or repository content. A successful read of this scalar demonstrates only the behavior of this query under the captured configuration bytes and context. It does not establish how every Git consumer interprets every setting.

The four contexts cross the team boundary in opposite directions:

Context ID

Checkout root

Intended profile

outside_main

<LAB>/repos/outside-main

fallback

linked_in

<LAB>/zone/team/linked-in

team

inside_main

<LAB>/zone/team/main-in

team

linked_out

<LAB>/other/linked-out

fallback

That crossing is what makes the test useful. A selector tied to administrative storage can miss linked_in and incorrectly select linked_out, creating both false-negative and false-positive policy outcomes.

This location contract is intentionally unrelated to whether a file exists in a commit. Refonte Learning’s article on sparse checkout and commit membership addresses that different evidence problem. Here, physical checkout location is configuration-selection input, not evidence about repository-tree membership.

Write the expected mapping before observing results

Expected state must be authored independently of captured state. Do not run Git, see team, and then fill team into the expectation column.

A compact manifest schema is:

{
  "manifest_version": "includeproof-v1",
  "case_id": "G03",
  "context_id": "linked_in",
  "declared_checkout_root": "<LAB>/zone/team/linked-in",
  "desired_profile": "team",
  "expected_source_file": "<LAB>/cfg/profiles/team.inc"
}

For fallback rows, expected_source_file is <LAB>/cfg/global.gitconfig. The checkout root is declared from the fixture plan and later reconciled against git rev-parse --show-toplevel; it is not copied from probe output.

The policy manifest is therefore:

outside_main  <LAB>/repos/outside-main       fallback  <LAB>/cfg/global.gitconfig
linked_in     <LAB>/zone/team/linked-in      team      <LAB>/cfg/profiles/team.inc
inside_main   <LAB>/zone/team/main-in        team      <LAB>/cfg/profiles/team.inc
linked_out    <LAB>/other/linked-out         fallback  <LAB>/cfg/global.gitconfig

If a probe cannot establish which declared context it ran in, that is not a successful fallback. It is missing identity evidence and should result in HOLD_EVIDENCE.

The selector decision comes later. First state what location determines policy. If the intended rule were administrative location, gitdir: might be the correct mechanism. For this article’s declared policy, the physical checkout root is authoritative, so any selector must be judged against that contract rather than against its own matching success.

Distinguish a selector from a configuration scope

Git’s gitdir: condition matches the location of the repository’s Git directory. When repository discovery encounters a .git file, as linked worktrees do, Git documents that matching uses the final Git-directory location to which that file points. By contrast, Git 2.56.1 documents worktree: as matching the current worktree’s checkout location, corresponding to git rev-parse --show-toplevel. The Git 2.56.1 git-config manual describes both inputs explicitly.

That difference matters because linked worktrees intentionally separate checked-out files from some administrative data. Git’s repository-layout documentation says linked-worktree administration lives under the common repository’s worktrees area and that a linked checkout normally has a .git file pointing to its real administrative directory. The repository-layout reference also documents the backlink from a linked-worktree administrative entry to the checkout.

Do not derive the private administrative path from the checkout basename or branch name. Git may choose an identifier with a suffix when an obvious name is already occupied. Capture the path through Git.

This is also not a configuration-scope exercise. Readers needing that distinction should use Refonte Learning’s shared versus worktree-specific configuration article. This experiment deliberately leaves extensions.worktreeConfig disabled and never performs a git config --worktree write.

Two separate questions remain:

  1. Selection: did the conditional include select team.inc under this invocation?

  2. Storage/scope: from which file and scope did the candidate value originate?

The test needs both, but they are not interchangeable. A global include can select a file based on a worktree path; that does not transform the value into worktree-scope configuration. Conversely, linked-worktree administrative storage does not mean a gitdir: condition follows the physical checkout directory.

The global file puts fallback before the conditional include. Git documents included content as entering configuration at the location of the include directive, so a matching fragment supplies a later team candidate. Relative path= values are resolved relative to the file containing the include directive.

The proof is not “the final scalar was right.” It is “the candidate set, winning scalar, origin and independently expected location mapping were all right.”

Construct the two-repository, four-checkout fixture

The following fixture uses two independent local repositories. For basic Git mechanics rather than this specialized selector test, see Refonte Learning’s basic Git version-control workflow.

Choose <LAB> as an already resolved absolute path containing no whitespace, control characters or glob metacharacters. A concrete run might assign it from realpath, but the published fixture keeps the placeholder so operators explicitly substitute their owned disposable root.

set -eu

LAB="<LAB>"
test -n "$LAB"
case "$LAB" in
  /*) ;;
  *) echo "LAB must be absolute" >&2; exit 2 ;;
esac

mkdir -p \
  "$LAB/repos" \
  "$LAB/zone/team" \
  "$LAB/other" \
  "$LAB/cfg/profiles" \
  "$LAB/evidence"

git init "$LAB/repos/outside-main"
git init "$LAB/zone/team/main-in"

# Bootstrap-only synthetic commits. These command-local values exist solely
# so Git can create a disposable commit; they are not part of the policy test.
git -C "$LAB/repos/outside-main" \
  -c user.name=fixture -c [email protected] \
  commit --allow-empty -m bootstrap

git -C "$LAB/zone/team/main-in" \
  -c user.name=fixture -c [email protected] \
  commit --allow-empty -m bootstrap

git -C "$LAB/repos/outside-main" branch linked-in-fixture
git -C "$LAB/zone/team/main-in" branch linked-out-fixture

git -C "$LAB/repos/outside-main" \
  worktree add "$LAB/zone/team/linked-in" linked-in-fixture

git -C "$LAB/zone/team/main-in" \
  worktree add "$LAB/other/linked-out" linked-out-fixture

git -C "$LAB/repos/outside-main" worktree list --porcelain
git -C "$LAB/zone/team/main-in" worktree list --porcelain

The synthetic commit metadata is only a bootstrap requirement for a convenient normal linked-worktree fixture; it is neither inspected nor used as a configuration input.

Create the fragment:

# <LAB>/cfg/profiles/team.inc
[lab]
    includeproof = team

G01 uses a fallback-only global file:

# <LAB>/cfg/global.gitconfig -- G01
[lab]
    includeproof = fallback

The gitdir: variant used by G02 is:

# <LAB>/cfg/global.gitconfig -- G02
[lab]
    includeproof = fallback

[includeIf "gitdir:<LAB>/zone/team/"]
    path = profiles/team.inc

The worktree: variant used by G03 and later cases is:

# <LAB>/cfg/global.gitconfig -- worktree variant
[lab]
    includeproof = fallback

[includeIf "worktree:<LAB>/zone/team/"]
    path = profiles/team.inc

The trailing slash is intentional: Git documents trailing-/ conditional patterns as prefix matching, effectively extending the pattern to content below that directory.

Keep configuration inputs inside the owned fixture

Probe processes should inherit only an allowlisted environment sufficient for execution. Preserve PATH, do not rewrite HOME, direct global configuration to the fixture, and disable system configuration:

import os

DROP_PREFIXES = (
    "GIT_DIR", "GIT_WORK_TREE", "GIT_COMMON_DIR",
    "GIT_INDEX_FILE", "GIT_OBJECT_DIRECTORY",
    "GIT_ALTERNATE_OBJECT_DIRECTORIES",
    "GIT_CONFIG_COUNT", "GIT_CONFIG_KEY_", "GIT_CONFIG_VALUE_",
)

def clean_env(global_config):
    env = {}
    for key in ("PATH", "HOME", "LANG", "LC_ALL", "TZ"):
        if key in os.environ:
            env[key] = os.environ[key]

    env["GIT_CONFIG_GLOBAL"] = str(global_config)
    env["GIT_CONFIG_NOSYSTEM"] = "1"

    for key in list(env):
        if key.startswith(DROP_PREFIXES):
            del env[key]
    return env

A production helper should also inspect the parent environment and reject unexpected repository-location or runtime-configuration injection variables rather than silently forwarding them.

Before probing, verify that neither repository-local configuration defines the inert key:

git -C "<LAB>/repos/outside-main" \
  --no-pager config --local get --all lab.includeproof >/dev/null 2>&1 &&
  { echo "unexpected local lab.includeproof" >&2; exit 1; } || :

git -C "<LAB>/zone/team/main-in" \
  --no-pager config --local get --all lab.includeproof >/dev/null 2>&1 &&
  { echo "unexpected local lab.includeproof" >&2; exit 1; } || :

Record exact configuration bytes before testing:

sha256sum \
  "<LAB>/cfg/global.gitconfig" \
  "<LAB>/cfg/profiles/team.inc"

Record fixture-path ownership or creation metadata using whatever local inventory format the operator controls, but make no filesystem-security conclusion from this experiment. The purpose is reproducibility: later evidence must say exactly which bytes and paths were queried.

Capture roots, origins and effective values

Each row needs three Git identities kept separate.

git rev-parse --show-toplevel reports the root of the working tree. --absolute-git-dir reports the canonical absolute private Git directory. --path-format=absolute --git-common-dir reports the common administrative directory in absolute form. The git-rev-parse manual defines those commands and notes that --git-common-dir yields the common directory when one is configured.

For a linked checkout, the private and common directories normally differ. Git’s repository-layout reference documents linked-worktree private administrative entries under the common worktrees area and the backlink stored there. Those relationships are why the script captures paths instead of fabricating an administrative identifier.

The same identity-separation habit appears in a different context in Refonte Learning’s article on submodule gitlinks and working revisions. This fixture does not add a submodule test.

A reusable subprocess probe can preserve raw evidence:

#!/usr/bin/env python3
import json, os, pathlib, subprocess, sys, hashlib, datetime

def sha256(path):
    return hashlib.sha256(pathlib.Path(path).read_bytes()).hexdigest()

def run(argv, cwd, env):
    p = subprocess.run(
        argv,
        cwd=cwd,
        env=env,
        stdout=subprocess.PIPE,
        stderr=subprocess.PIPE,
        text=False,
    )
    return {
        "argv": argv,
        "cwd": str(cwd),
        "status": p.returncode,
        "stdout_hex": p.stdout.hex(),
        "stderr_hex": p.stderr.hex(),
    }

def text_ok(record):
    if record["status"] != 0:
        return None
    return bytes.fromhex(record["stdout_hex"]).decode("utf-8").rstrip("\n")

def identity(git, cwd, env):
    top = run([git, "rev-parse", "--show-toplevel"], cwd, env)
    private = run([git, "rev-parse", "--absolute-git-dir"], cwd, env)
    common = run(
        [git, "rev-parse", "--path-format=absolute", "--git-common-dir"],
        cwd, env,
    )
    return {
        "checkout_root": text_ok(top),
        "private_git_dir": text_ok(private),
        "common_git_dir": text_ok(common),
        "raw_identity": [top, private, common],
    }

Before any case, resolve and record the actual executable and versions:

command -v git
git --version
python3 --version
uname -srm

Do not treat anticipated strings such as git version 2.56.1 as captured data. The run either records that value or it does not. If command -v git resolves a different binary or git --version is not the proposed baseline, the record must show the discrepancy.

Record the query contract

Git 2.56.1 documents the modern git config get form, including --all, --show-origin, --show-scope, --includes and --no-includes. --show-origin annotates results with their actual origin, while --show-scope adds scope. Git also documents include processing as normally enabled when searching all configuration and normally disabled for reads constrained to a specific file or scope; this playbook therefore sets the include flag explicitly. The 2.56.1 git-config options are the query contract.

Capture candidates:

git -C "<CHECKOUT>" config get \
  --includes \
  --all \
  --show-origin \
  --show-scope \
  lab.includeproof

Then capture the selected scalar separately:

git -C "<CHECKOUT>" config get \
  --includes \
  lab.includeproof

Do not infer the winner by casually taking the final text token from a provenance line. Preserve raw stdout and parse only the narrow expected format. The fixture disallows whitespace and control characters in its owned paths specifically to keep this parser contract small; configuration values are restricted to fallback and team.

A query made with --no-includes is a distinct observation. A query constrained with --global or --file is also distinct because Git documents different include defaults for such selected-file/scope reads. Evidence should therefore store the complete argument vector and an explicit includes_enabled field.

Expose the two gitdir policy mismatches

G01 establishes the baseline. Install only the fallback file and probe all four contexts with explicit --includes.

G01 documented expectation: all four contexts produce one fallback candidate from <LAB>/cfg/global.gitconfig, and the selected scalar is fallback. That case demonstrates that the context inventory and fallback path are wired correctly; it does not yet test a condition.

G02 installs the gitdir:<LAB>/zone/team/ variant. Git documents gitdir: as matching the actual Git-directory path, including the resolved target when worktree discovery uses a .git file.

Given this fixture design, the documented expectation is:

Context

Intended profile

G01 expected

G02 gitdir: expected

G02 policy result

outside_main

fallback

fallback

fallback

conforming

linked_in

team

fallback

fallback

wrong policy

inside_main

team

fallback

team

conforming

linked_out

fallback

fallback

team

wrong policy

Why? linked_in is physically under <LAB>/zone/team/, but its private administrative directory belongs to outside_main’s repository and is expected outside that team pathname. linked_out is physically outside the team directory, yet its private administrative directory belongs to the inside_main repository whose .git storage is under <LAB>/zone/team/.

Those path relationships must be confirmed from the rev-parse captures, not inferred from this explanation.

A minimal case driver is:

CONTEXTS = {
    "outside_main": "<LAB>/repos/outside-main",
    "linked_in":    "<LAB>/zone/team/linked-in",
    "inside_main":  "<LAB>/zone/team/main-in",
    "linked_out":   "<LAB>/other/linked-out",
}

def probe_context(case_id, context_id, git, env):
    cwd = CONTEXTS[context_id]
    ident = identity(git, cwd, env)

    candidates = run([
        git, "config", "get",
        "--includes", "--all",
        "--show-origin", "--show-scope",
        "lab.includeproof",
    ], cwd, env)

    selected = run([
        git, "config", "get",
        "--includes",
        "lab.includeproof",
    ], cwd, env)

    return {
        "case_id": case_id,
        "context_id": context_id,
        **ident,
        "candidates_raw": candidates,
        "selected_raw": selected,
        "includes_enabled": True,
    }

Preserve G01 and G02 in separate evidence directories. Do not replace the G02 rows after introducing a different selector. G02 is valuable precisely because it should show a mechanism-conforming but policy-nonconforming mapping if Git behaves according to the documentation.

That distinction prevents a bad remediation habit: changing the policy statement after seeing that Git selected a fragment. The selector should be evaluated against the declared policy, not vice versa.

Qualify the worktree selector on the actual executable

G03 replaces only the global configuration bytes:

[lab]
    includeproof = fallback

[includeIf "worktree:<LAB>/zone/team/"]
    path = profiles/team.inc

The independent intended mapping stays exactly the same: fallback, team, team, fallback.

Git’s official 2.56 release notes say the conditional-inclusion facility was taught to use the worktree location as a condition in Git 2.56. The Git v2.56 release notes establish that release attribution. The proposed Git 2.56.1 laboratory baseline is then anchored to the versioned Git 2.56.1 configuration manual, which describes worktree: as matching the working-tree location and distinguishes it from gitdir:.

A version string alone is not sufficient evidence. Record:

command -v git
git --version

and preserve those raw results in the run metadata. Then run G03 on all four contexts. The documented expectation is:

outside_main  fallback  origin global.gitconfig
linked_in     team      winning origin team.inc
inside_main   team      winning origin team.inc
linked_out    fallback  origin global.gitconfig

The case passes the intended policy only if the captured checkout root equals the manifest root, the profile is correct, and the provenance is consistent with selection.

Require a positive and a negative capability witness

Before ADOPT_WORKTREE is even eligible, G03 must contain both:

  • a positive witness, such as linked_in, whose recorded root is beneath the real team directory and whose team value is traced to <LAB>/cfg/profiles/team.inc; and

  • a negative witness, such as outside_main, whose recorded root is outside the team directory and whose result remains fallback from the global file.

If either witness is absent, failed, ambiguous, or has an unexpected origin, return HOLD_CAPABILITY.

This rule matters especially when the actual executable is not the proposed 2.56.1 baseline. Fallback on an unqualified client cannot be interpreted as “the policy says fallback.” It may instead mean that the condition was unsupported, malformed, not processed under the captured flags, or evaluated against unexpected state.

Retain both the G02 gitdir: configuration bytes and G03 worktree: bytes with digests. That makes the eventual decision reversible and keeps KEEP_GITDIR, ADOPT_WORKTREE and RESTORE grounded in known artifacts rather than manually reconstructed text.

Check nested invocations and relative include paths

G04 asks whether entering the repository through different owned directories changes the identity or selected fragment.

Create one nested directory in each clean checkout:

mkdir -p "<LAB>/repos/outside-main/.lab-nested/a"
mkdir -p "<LAB>/zone/team/linked-in/.lab-nested/a"
mkdir -p "<LAB>/zone/team/main-in/.lab-nested/a"
mkdir -p "<LAB>/other/linked-out/.lab-nested/a"

For each context, capture three independent invocations:

(
  cd "<CHECKOUT>"
  git rev-parse --show-toplevel
  git config get --includes --show-origin lab.includeproof
)

(
  cd "<CHECKOUT>/.lab-nested/a"
  git rev-parse --show-toplevel
  git config get --includes --show-origin lab.includeproof
)

git -C "<CHECKOUT>" rev-parse --show-toplevel
git -C "<CHECKOUT>" config get --includes --show-origin lab.includeproof

G04 documented expectation: root-level, nested-CWD and explicit -C invocations resolve to the same checkout root for a given context and select the same origin/value under unchanged bytes. A mismatch is investigation material, not a reason to normalize output after capture.

G05 tests relative include anchoring. Leave:

[includeIf "worktree:<LAB>/zone/team/"]
    path = profiles/team.inc

in <LAB>/cfg/global.gitconfig, then vary only the invocation working directory. Git documents a relative include path as relative to the configuration file containing the directive, not relative to the process CWD and not relative to the matched directory.

Therefore the expected included file is always:

<LAB>/cfg/profiles/team.inc

For each matching context, require the recorded candidate origin to equal that absolute path after the evidence parser normalizes Git’s reported file: origin according to its restricted fixture assumptions.

Do not accept team with a surprising origin. The same scalar could have appeared because a stray repository-local setting, an unexpected configuration source, or a different included file supplied it. G05 is specifically an origin test.

Conversely, a correct fragment path with a failed query status is not a passing value test. Status, identity, candidates and selected scalar are separately mandatory fields.

The failure diagnosis should therefore remain bounded:

wrong root      -> context/invocation problem
right root,
wrong origin    -> include anchoring/config-input problem
right origin,
wrong scalar    -> fragment contents or parsing problem
nonzero status  -> command/configuration failure; do not synthesize fallback

Make include-processing flags part of the test

G06 freezes one known matching context, for example inside_main, and varies only the explicit include flag.

Production-contract query:

git -C "<LAB>/zone/team/main-in" \
  config get --includes --all --show-origin --show-scope \
  lab.includeproof

Control query:

git -C "<LAB>/zone/team/main-in" \
  config get --no-includes --all --show-origin --show-scope \
  lab.includeproof

With the worktree-conditioned global file installed, the documented expectation is that the first query exposes both the global fallback and the matching fragment candidate, with team selected by the separate scalar read. The suppressed-include control is expected to expose only fallback, because the conditional fragment is deliberately not processed.

Git 2.56.1 documents --includes and --no-includes explicitly and says include processing defaults off when a specific configuration file or scope is selected, but on when searching the normal configuration set. That is exactly why implicit defaults are poor evidence: two diagnostic commands can look similar while answering different questions.

The G06 --no-includes fallback is not a selector repair and must not overwrite the production-policy verdict. It is an intentional negative control demonstrating that the included fragment is actually responsible for the team candidate.

The broader operational lesson resembles Refonte Learning’s effective OpenSSH configuration validation: validate the effective behavior under the actual query context rather than relying only on source text. Do not transfer OpenSSH’s Include/Match grammar, precedence or daemon semantics to Git; only the evidence discipline is analogous.

Store these records separately:

G06/includes-enabled.json
G06/includes-suppressed.json

A reviewer should be able to distinguish “expected negative control behaved as designed” from “production-policy query failed.” Mixing those verdicts creates false repairs.

Revalidate after relocation and path aliasing

G07 changes one physical location using Git’s worktree-management command. Start from the declared baseline with linked_in at:

<LAB>/zone/team/linked-in

Capture its pre-move roots, then run:

git -C "<LAB>/repos/outside-main" \
  worktree move \
  "<LAB>/zone/team/linked-in" \
  "<LAB>/other/linked-in-moved"

Record the command’s actual exit status and raw output before doing anything else.

Git’s worktree manual documents git worktree move, and notes that the main worktree and linked worktrees containing submodules are not eligible for this relocation operation. This fixture intentionally moves a clean linked worktree without submodules.

Version the manifest for the relocated state:

{
  "manifest_version": "includeproof-v1-g07-moved",
  "context_id": "linked_in",
  "declared_checkout_root": "<LAB>/other/linked-in-moved",
  "desired_profile": "fallback",
  "expected_source_file": "<LAB>/cfg/global.gitconfig"
}

Then probe in a fresh subprocess. G07 documented expectation under worktree: is that the moved checkout now receives fallback, because its physical root crossed out of the team directory.

Capture private and common Git directories both before and after. Do not infer whether either administrative path changed from the destination basename. The administrative identities are measurements supplied by rev-parse.

Restore the fixture with another recorded move:

git -C "<LAB>/repos/outside-main" \
  worktree move \
  "<LAB>/other/linked-in-moved" \
  "<LAB>/zone/team/linked-in"

Probe again in a fresh process and require the original team mapping and expected fragment origin before G08 begins.

Distinguish a symlink alias from the physical root

G08 creates an owned alias:

ln -s "<LAB>/zone/team" "<LAB>/team-alias"

Now compare two configuration variants:

[includeIf "worktree:<LAB>/team-alias/"]
    path = profiles/team.inc

and:

[includeIf "worktree:<LAB>/zone/team/"]
    path = profiles/team.inc

Invoke through the alias, for example:

cd "<LAB>/team-alias/linked-in"
git rev-parse --show-toplevel
git config get --includes --show-origin lab.includeproof

Git 2.56.1 currently documents a limitation specific to worktree: conditions. Matching uses the realpath-resolved worktree location, so a condition written using a symbolic-link spelling may not match even when the process entered through that alias.

Therefore G08 records four distinct facts: the logical invocation path supplied by the driver, the canonical checkout root reported by Git, the alias-spelled condition, and the physical-path condition.

The alias-spelled condition is an intentional documented nonmatch control; the physical condition is expected to match. Do not turn that observation into a filesystem-containment or authorization claim. This is only a configuration-selector test.

Build a case ledger with separate mechanism and policy results

The evidence bundle needs enough information to audit the assertion after the shell session is gone.

A record is a schema, not an invented transcript:

Field

Required meaning

run_id, captured_at

Attempt identity and timestamp from the real run

case_id, context_id

G01–G10 and manifest context

manifest_version, manifest_sha256

Exact independent expectation set

git_executable, git_version

Actual binary path and captured version

helper_runtime_version

Actual Python/helper runtime

argv, cwd

Complete invocation contract

checkout_root

Captured --show-toplevel

private_git_dir

Captured --absolute-git-dir

common_git_dir

Captured absolute common directory

global_config_sha256, fragment_sha256

Exact queried configuration bytes

includes_enabled

Explicit include-processing state

candidate_values

Parsed values plus origins and scopes

selected_scalar

Result of separate scalar query

exit_status

Actual command status

stdout_raw, stderr_raw

Lossless raw capture

mechanism_result

Selector behavior vs documented expectation

policy_result

Result vs independently declared policy

reason

Human-reviewable verdict reason

A JSON row could be shaped as follows:

{
  "run_id": "UNSET_UNTIL_EXECUTION",
  "captured_at": null,
  "case_id": "G03",
  "context_id": "linked_in",
  "manifest_version": "includeproof-v1",
  "manifest_sha256": null,
  "git_executable": null,
  "git_version": null,
  "helper_runtime_version": null,
  "argv": [],
  "cwd": "<LAB>/zone/team/linked-in",
  "checkout_root": null,
  "private_git_dir": null,
  "common_git_dir": null,
  "configuration_digests": {},
  "includes_enabled": true,
  "candidate_values": [],
  "selected_scalar": null,
  "exit_status": null,
  "stdout_raw": null,
  "stderr_raw": null,
  "mechanism_result": "UNMEASURED",
  "policy_result": "UNMEASURED",
  "reason": "Laboratory not executed"
}

The manifest must enumerate the mandatory case-context set before execution. Ten named cases do not mean ten command invocations: G01–G03 each include multiple contexts; G04 includes root, nested and -C forms; G06 contains two include modes; G07 has pre-move, moved and restored states.

A useful case ledger is:

Case

Required evidence purpose

G01

Four-context fallback baseline

G02

Four-context gitdir: selector mapping

G03

Four-context worktree: capability/policy mapping

G04

Nested and explicit -C invocation consistency

G05

Relative include origin anchoring

G06

--includes versus --no-includes control

G07

Relocation plus restoration

G08

Symlink-spelled versus realpath-spelled condition

G09

Malformed fragment failure plus recovered query

G10

Reconciler rejection of incomplete/corrupted evidence copies

An expected negative control can prove mechanism behavior while blocking policy acceptance. G02’s linked_in row, for example, is expected to show gitdir: correctly refusing the team fragment even though that result violates the physical-checkout policy. Keep those two verdict columns separate.

Every attempt and every restored state gets a distinct artifact. Never edit a failed record into a successful one.

Reject malformed fragments and restore known bytes

G09 operates on one isolated known-matching context with the worktree: configuration active.

First save the exact profile fragment and digest:

cp "<LAB>/cfg/profiles/team.inc" \
   "<LAB>/evidence/G09.team.inc.saved"

sha256sum \
  "<LAB>/cfg/profiles/team.inc" \
  "<LAB>/evidence/G09.team.inc.saved"

Then replace the fragment with deliberately invalid configuration inside the owned fixture:

cat >"<LAB>/cfg/profiles/team.inc" <<'EOF'
[lab
    includeproof = team
EOF

Run the intended query, preserving its real status, stdout and stderr:

git -C "<LAB>/zone/team/main-in" \
  config get --includes --all --show-origin --show-scope \
  lab.includeproof

Do not record an anticipated exit code or diagnostic as captured evidence. The required expectation is categorical: malformed configuration should make the intended query fail rather than become a successful fallback observation. The actual run must capture whatever diagnostic and nonzero status the tested executable emits.

Restore exact known bytes:

cp "<LAB>/evidence/G09.team.inc.saved" \
   "<LAB>/cfg/profiles/team.inc"

sha256sum \
  "<LAB>/cfg/profiles/team.inc" \
  "<LAB>/evidence/G09.team.inc.saved"

Digest equality proves byte restoration, not configuration-policy recovery. A fresh process must repeat the production query:

git -C "<LAB>/zone/team/main-in" \
  config get --includes --all --show-origin --show-scope \
  lab.includeproof

git -C "<LAB>/zone/team/main-in" \
  config get --includes \
  lab.includeproof

The documented recovered expectation is team with the team fragment present at the expected origin.

Preserve both states:

G09/malformed/
G09/restored/

If byte restoration succeeds but the recovered mapping or origin does not, the correct outcome is not “restored.” It is evidence of a remaining configuration or invocation defect and should lead to REPAIR_PATTERN_OR_FRAGMENT or HOLD_EVIDENCE, depending on what is known.

Prove the reconciler rejects incomplete evidence

G10 does not damage Git state. It makes authored validation mutations to copies of the evidence bundle and verifies that reconciliation fails closed.

The reconciler should first derive the required row keys from the independent manifest, not from whatever evidence happened to be captured:

#!/usr/bin/env python3
import collections

def reconcile(manifest, records):
    reasons = []

    required = {
        (row["case_id"], row["context_id"], row["state_id"])
        for row in manifest["required_rows"]
    }

    keys = [
        (r.get("case_id"), r.get("context_id"), r.get("state_id"))
        for r in records
    ]

    counts = collections.Counter(keys)

    missing = sorted(required - set(keys))
    duplicates = sorted(k for k, n in counts.items() if n != 1 and k in required)

    if missing:
        reasons.append(f"missing required rows: {missing}")
    if duplicates:
        reasons.append(f"duplicate required rows: {duplicates}")

    for r in records:
        key = (r.get("case_id"), r.get("context_id"), r.get("state_id"))
        if key not in required:
            continue

        if r.get("manifest_version") != manifest["manifest_version"]:
            reasons.append(f"{key}: manifest version mismatch")

        if r.get("exit_status") != 0 and not r.get("expects_failure", False):
            reasons.append(f"{key}: unexpected nonzero command status")

        for field in ("checkout_root", "private_git_dir", "common_git_dir"):
            if not r.get(field):
                reasons.append(f"{key}: missing {field}")

        expected = manifest["expectations"][key]
        if r.get("selected_scalar") != expected["profile"]:
            reasons.append(f"{key}: profile mismatch")

        if r.get("selected_origin") != expected["origin"]:
            reasons.append(f"{key}: origin mismatch")

    if reasons:
        return {"decision": "HOLD_EVIDENCE", "reasons": reasons}
    return {"decision": "COMPLETE", "reasons": []}

A production implementation should add digest checks, capability-witness semantics and explicit handling for cases such as G09 where a nonzero status is itself required. The essential property shown here is that missing proof cannot silently collapse into a default profile.

Create three copies:

import copy

missing = copy.deepcopy(records)
missing.pop(0)

duplicate = copy.deepcopy(records)
duplicate.append(copy.deepcopy(duplicate[0]))

wrong_origin = copy.deepcopy(records)
wrong_origin[0]["selected_origin"] = "<LAB>/cfg/unexpected.inc"

for sample in (missing, duplicate, wrong_origin):
    result = reconcile(manifest, sample)
    assert result["decision"] == "HOLD_EVIDENCE"
    assert result["reasons"]

These mutations are validation tests, not claims that Git corrupted anything.

Make missing and duplicated rows fail closed

A planned negative control is complete evidence. It has a known case, context, configuration digest, query, status, identities, expected result and actual raw capture.

A missing row has none of those facts. Treating absence as fallback would erase the distinction between “Git was asked and did not select the include” and “Git was never asked under the required context.”

Likewise, two rows with the same required identity are not automatically stronger evidence. They may represent accidental retries, different configuration bytes, or mixed restored and pre-restoration states. Require a unique key that includes enough state identity to distinguish intentional attempts.

HOLD_EVIDENCE should name the bounded rerun. For example:

Owner: operator
Reason: missing G03/linked_out/baseline
Rerun: only G03 linked_out with the recorded G03 configuration digest
Reviewer action: reconcile complete manifest again

Missing capability witnesses are owned differently: the repository/platform owner must first decide which executable baseline is acceptable, while the operator supplies the requested capture.

No policy may be accepted until mandatory restoration rows are present. A run that demonstrates a move or malformed fragment but never demonstrates recovery remains incomplete even if every earlier selector assertion passed.

Decide which selector to keep and who owns the change

The final decision is based on the declared policy, demonstrated capability and complete evidence, not on selector novelty.

Decision

Use when

Required next action

KEEP_GITDIR

Administrative Git-directory location is actually the intended policy and complete evidence conforms

Keep recorded gitdir: bytes; document that policy explicitly

ADOPT_WORKTREE

Physical checkout location is the intended policy, the positive/negative capability witnesses pass, and the complete matrix conforms

Adopt the recorded worktree: bytes through the owner’s normal change process

REPAIR_PATTERN_OR_FRAGMENT

Evidence identifies a bounded wrong pattern, wrong include path, wrong fragment bytes or similarly isolated defect

Repair only the identified bytes, digest them and rerun affected mandatory rows

HOLD_CAPABILITY

Actual executable does not demonstrate a conclusive supported worktree: positive and negative witness

Do not infer policy from fallback; resolve client capability separately

HOLD_EVIDENCE

Required rows, identities, digests, origins, statuses or restored-state captures are missing/ambiguous

Capture only the specified missing proof, then reconcile again

RESTORE

A trial configuration or eligible worktree relocation must be returned to recorded known state

Restore recorded bytes/location and perform fresh verification

Do not automatically edit a developer’s real global configuration or recommend an automatic upgrade merely because worktree: better expresses this fixture’s physical-location contract. The proposed Git 2.56.1 baseline is a reproducibility target. Deployment ownership and compatibility policy remain separate decisions.

Responsibility should also be explicit:

  • Repository/platform owner: owns the policy statement, acceptable Git capability baseline, selector choice and any adoption decision.

  • Operator: owns fixture setup, immutable captures, digests, command records, relocation/restoration operations and bounded reruns.

  • Reviewer: checks completeness, independence of expectations, mechanism-versus-policy verdicts and recovery evidence before acceptance.

Guarded cleanup begins only after the evidence bundle is preserved. Cleanup code should verify a nonempty expected root and compare it to the recorded fixture root before removal:

LAB="<LAB>"
test -n "$LAB"
test "$LAB" = "<RECORDED_FIXTURE_ROOT>" || {
  echo "fixture root mismatch; refusing cleanup" >&2
  exit 1
}

# Preserve/copy the evidence bundle first.
rm -rf -- "$LAB"

Acceptance for this article’s physical-checkout policy requires all of the following: the real executable and version were captured; G03 has positive and negative capability witnesses; all mandatory manifest rows are unique and complete; G01–G10 have their required evidence states; G04 and G05 preserve root and origin expectations; G06 proves include suppression separately; G07 demonstrates move-sensitive remapping and restoration; G08 documents realpath behavior; G09 preserves failure and recovered evidence; G10 proves incomplete evidence is rejected; and the four production-policy contexts finish as fallback, team, team, fallback from their expected origins.

If an actual Git 2.56.1 run differs from the cited documentation, preserve the discrepancy and hold the decision. Do not modify the expected policy until output looks green.

The resulting conclusion is deliberately narrow. It covers this executable, these configuration bytes, these four declared location contexts, these test controls and this scalar query contract. It does not make path matching an authorization boundary and does not establish behavior for unrelated Git consumers.

Extend the practice through Refonte Learning

The useful engineering skill here is broader than memorizing a new conditional keyword. The durable practice is to separate intended policy from implementation mechanism, record configuration provenance, test positive and negative witnesses, preserve recovery evidence, and fail closed when the evidence set is incomplete.

Those habits connect directly to version-control fundamentals and reproducible DevOps troubleshooting. Refonte Learning’s DevOps Engineering Program is listed as a three-month program requiring 12–14 hours per week and describes admission for learners engaged in bachelor’s or postgraduate study. Its published curriculum includes Linux fundamentals, Git and GitHub, CI/CD, Docker and Kubernetes, Terraform, AWS/Azure/GCP, monitoring and logging, and a capstone; the page also describes mentor guidance, virtual internship opportunities and Training and Internship certificates on successful completion.

The program page lists DevOps Engineer, Cloud Engineer and Site Reliability Engineer as career results or paths; those labels should not be read as guaranteed placements. The page does not establish that this exact Git 2.56.1 conditional-include laboratory is part of the curriculum, so no such claim is made here.

For engineers building platform ownership around Git, the relevant next step is to apply the same discipline to their own disposable environment: state the directory policy first, capture the actual client and configuration bytes, run the complete manifest, and choose a selector only after mechanism behavior and policy conformance have both been demonstrated.