Desk Clarity

A field guide to everyday digital problems.

Developer tools / Practical guide

Git Setting Comes from the Wrong File: Inspect Origin and Scope

Trace a configuration key before editing global or repository settings.

By ON Lab2 min readSources checked November 10, 2026 (KST)

Use git config --show-origin --show-scope --get-all KEY to trace a setting across loaded configuration sources. A value-only listing hides where it was defined. Inspect the key before changing a broad configuration file.

Reproduce the boundary in a disposable fixture

Trace a configuration key before editing global or repository settings.

Use a new empty temporary directory for this fixture. The example creates only local test data. Commands marked with example.invalid do not identify a real service.

git init -q demo
cd demo
git config --local fixture.mode local-value
git -c fixture.mode=command-value config --show-origin --show-scope --get-all fixture.mode
test "$(git config --local --get fixture.mode)" = local-value
git config --show-origin --show-scope --get-all fixture.mode

Observed result

local	file:.git/config	local-value
command	command line:	command-value
local	file:.git/config	local-value

What the result means

The command-scoped invocation shows both the local value and the value supplied with -c, with their sources and scopes. The later invocation still reads the original local value because -c did not save a new setting. This fixture uses an otherwise irrelevant custom key so it does not alter signing, identity, credentials, remotes or any operational user policy.

Choose the correction for your workflow

Run the source-tracing command for the exact key involved in the failure. Read every returned entry and consider includes, environment or command-scoped settings. For many single-valued keys, a later value wins; other keys are multi-valued or interpreted by their consuming command, so do not choose a winner solely by appearance. Edit the intended scope explicitly and read the same key with its origin afterwards. In scripts, check whether the key is absent and handle the command exit status rather than assuming an empty value is a successful lookup.

Limits and the next check

Git versions differ in newer config subcommand support; the fixture uses the established option syntax and requires --show-scope support. This does not prove that a GUI, hook, sudo invocation or separate process loads the same configuration. Reproduce the lookup under the process context that sees the problem. Configuration output can expose private paths or credential-bearing values, so preserve only the needed evidence and redact sensitive fields before sharing it.

Related: Compare the related workflow boundary.

This isolated example was executed on macOS on November 10, 2026 (KST). Available tools: node v26.5.0, git git version 2.39.3 (Apple Git-145), npm 11.17.0, jq jq-1.7.1-apple. Shell fixtures use Bash and repository-path identity uses Python 3. This checks the illustrated contract, not your project, host service or every tool version.

Sources & further reading