git config --global: Usage, Options & Common CI Errors
git config --global writes settings that apply to every repo for the current user.
CI jobs lean on global config to set a bot identity, default branch, and the safe.directory exceptions that newer Git requires inside containers.
What it does
git config --global reads and writes the per-user config file (~/.gitconfig or $XDG_CONFIG_HOME/git/config), affecting all repositories run by that user.
Common usage
Terminal
git config --global user.name "CI Bot"
git config --global user.email "ci@example.com"
git config --global init.defaultBranch main
git config --global --add safe.directory /workspace
git config --global --listOptions
| Flag | What it does |
|---|---|
| --global | Use the per-user config file |
| --add <key> <value> | Append a multi-valued key |
| --get <key> | Read a value |
| --unset <key> | Remove a value |
| --list | Show all effective settings |
Common errors in CI
fatal: detected dubious ownership in repository at ‘<dir>’ - the checkout is owned by a different uid than the running user (common with Docker). Fix with git config --global --add safe.directory <dir>. If $HOME is unset, --global has nowhere to write; export HOME or use --file.
Related guides
git config --local: Usage, Options & Common CI Errorsgit config --local writes settings into a single repo’s .git/config. Reference for per-repo identity, scope p…
git config: Usage, Options & Common CI Errorsgit config gets and sets Git configuration at system, global, and local scope. Reference for --global, --get,…
git init: Usage, Options & Common CI Errorsgit init creates a new empty Git repository or reinitializes an existing one. Reference for --bare, --initial…
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…