Skip to content
LatchkeyLatchkey home

git config --local: Usage, Options & Common CI Errors

git config --local stores settings that apply only to the current repository.

Use local config to scope a bot identity, credential, or option to one checkout without leaking it to the whole runner. Local always wins over global and system.

What it does

git config --local reads and writes the repository config at .git/config, which takes precedence over --global and --system for that repository only.

Common usage

Terminal
git config --local user.email "bot@example.com"
git config --local core.autocrlf false
git config --local --get remote.origin.url
git config --local --list

Options

FlagWhat it does
--localUse the repository .git/config (default in a repo)
--get <key>Read a value
--unset <key>Remove a value
--listShow settings from this scope
--show-originReveal which file a value comes from

Common errors in CI

fatal: --local can only be used inside a git repository - you ran it before cloning or in the wrong directory. Remember precedence: local overrides global, so a stray local user.email shadows the global one; use --show-origin to find which file a surprising value lives in.

Using this in CI

CI checkouts are shallow and detached by default, which changes the answer this command gives you. Commands that read history, branch names, or tags need the checkout configured for it.

.github/workflows/ci.yml
- uses: actions/checkout@v4
  with:
    fetch-depth: 0   # history, tags, and git describe all need this

- run: |
    git rev-parse --is-shallow-repository   # expect false
    git rev-parse --abbrev-ref HEAD          # prints HEAD when detached

Frequently asked questions

git config --local: Usage, Options & Common CI Errors?
Use local config to scope a bot identity, credential, or option to one checkout without leaking it to the whole runner. Local always wins over global and system.
What it does?
git config --local reads and writes the repository config at .git/config, which takes precedence over --global and --system for that repository only.
Common errors in CI?
fatal: --local can only be used inside a git repository - you ran it before cloning or in the wrong directory. Remember precedence: local overrides global, so a stray local user.email shadows the global one; use --show-origin to find which file a surprising value lives in.

Related guides

References

Run this faster and cheaper on Latchkey managed runners - self-healing included. Start free → 30-day trial · No credit card