Skip to content
Novus Examples
gitconfig532 B

Gitconfig - includeIf Conditions in Four Flavours

Every conditional-include form git supports — path prefix, case-insensitive path prefix, branch glob, and a condition on an existing remote URL — plus one unconditional include. Order matters: a later include overrides an earlier one, so a parser that gathers includes into a set rather than a list resolves the wrong identity.

Preview — first 18 linesgitconfig
[user]
	name = Ada Fernsby
	email = ada.fernsby@example.invalid

# Later includes win, and an includeIf is evaluated where it appears — moving one
# of these blocks changes which identity a repository ends up with.
[includeIf "gitdir:~/work/"]
	path = ~/.gitconfig-work
[includeIf "gitdir/i:~/Work/"]
	path = ~/.gitconfig-work
[includeIf "onbranch:release/**"]
	path = ~/.gitconfig-release
[includeIf "hasconfig:remote.*.url:ssh://git@git.example.invalid/**"]
	path = ~/.gitconfig-internal

[include]
	path = ~/.gitconfig-aliases

Specifications

Seed
20260807
Repository Name
~/.gitconfig
Includes
5
Conditional Includes
4
Conditions
gitdir, gitdir/i, onbranch, hasconfig
Line Endings
LF
Encoding
UTF-8

Testing contract

Expected to pass
Scenario
Resolve user.email for a repository under ~/work while checked out on release/4.3.
Expected result
Includes are applied in file order, so the last matching include wins; a set-based implementation that loses the ordering resolves a different identity.

What is a .gitconfig file?

A .gitconfig file holds Git configuration in an INI-like syntax: bracketed section headers, optional subsection names in quotes, and `key = value` pairs. The same grammar serves the system, global, and per-repository files, which are layered in that order, and values may be booleans, integers with `k`/`m`/`g` suffixes, colours, or paths. Comments begin with `#` or `;`.

How to use this file

Use an example .gitconfig file to test INI-style configuration parsers and Git tooling, checking quoted subsection names, value continuation, boolean coercion, and precedence when the same key appears more than once.

How to use this file for testing

“Gitconfig - includeIf Conditions in Four Flavours” is a deterministic Novus Examples fixture for Config parsing, Config testing, Visual diff / regression. TOML and INI configuration files with nested sections and typed values — for testing config parsers and loaders.

Documented properties for this file: seed 20260807 · UTF-8 · LF. Compare results against paired or grouped companions on this page when present (clean↔damaged, searchable↔scanned, or format twins) so scores stay reproducible across runs.

Download the file once, keep the path stable in CI or local scripts, and treat the spec table as the contract: dimensions, seeds, field lists, and roles are intentional. Corrupt or invalid samples are labelled as such — expect parsers to fail loudly rather than silently accept them.

Diff and patch fixtures name their target paths and the exact edge case they exercise — rename, mode change, binary hunk, CRLF↔LF, or missing trailing newline. Apply or render them against the documented before-state; every author, path, and hash is fictional.

Point your config loader at the file and assert it reads the documented sections and typed values, including any deliberately-tricky nesting or comments.

Generated by generation/version_control.py. Free for any use, no attribution required — license.