Skip to content
Latchkey

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 --list

Options

FlagWhat it does
--globalUse the per-user config file
--add <key> <value>Append a multi-valued key
--get <key>Read a value
--unset <key>Remove a value
--listShow 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

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