Skip to content
Latchkey

git config: Usage, Options & Common CI Errors

git config reads and writes the settings that control how Git behaves.

Config drives identity, line endings, and dozens of behaviors. CI usually sets user identity and safe.directory.

What it does

git config reads or writes key/value settings in one of three files: system (--system), global (--global, per user), or local (--local, per repo, the default for writes).

Common usage

Terminal
git config user.email "ci@example.com"
git config --global init.defaultBranch main
git config --get remote.origin.url
git config --global --add safe.directory '*'
git config -l                 # list everything

Options

FlagWhat it does
--global / --local / --systemChoose which config file to use
--get / --get-allRead a value (or all values)
--addAppend a value to a multi-valued key
--unsetRemove a value
-l / --listPrint all settings

Common errors in CI

fatal: detected dubious ownership in repository at '…' - the checkout is owned by a different user than the one running git (common in containers). Fix with git config --global --add safe.directory '<path>' (or '*'). Missing user.email/name triggers the commit identity error.

Related guides

Run this faster and cheaper on Latchkey managed runners. Start free →