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 everythingOptions
| Flag | What it does |
|---|---|
| --global / --local / --system | Choose which config file to use |
| --get / --get-all | Read a value (or all values) |
| --add | Append a value to a multi-valued key |
| --unset | Remove a value |
| -l / --list | Print 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
git commit: Usage, Options & Common CI Errorsgit commit records staged changes as a new commit. Reference for -m, --amend, --no-verify, and the empty-comm…
git init: Usage, Options & Common CI Errorsgit init creates a new empty Git repository or reinitializes an existing one. Reference for --bare, --initial…
git remote: Usage, Options & Common CI Errorsgit remote manages the named connections to remote repositories. Reference for add, set-url, -v, remove, and…
git clone: Usage, Options & Common CI Errorsgit clone copies a remote repository into a new local directory. Reference for depth, branch, and submodule f…