# git config Command: Configure Git in CI

> git config reads and writes Git settings. Reference for user.email, --global, and credential.helper to set up commit identity and auth on CI runners.

Source: https://latchkey.dev/learn/command-reference/git-config-command-reference  
Updated: 2026-06-26

git config gets and sets configuration values that control Git behavior at the repo, user, or system level.

Fresh CI runners have no identity or credentials configured. Before a job can commit or authenticate, it usually sets user.email, user.name, and a credential helper.

## Common flags

- `--global` - write to the per-user config (~/.gitconfig) instead of the repo
- `--local` - write to the repository config (the default)
- `--system` - write to the system-wide config
- `--add <key> <value>` - append a value to a multi-valued key
- `--get <key>` - print the value of a key
- `--unset <key>` - remove a key

## Example

```shell
# Set a bot identity so an automated commit succeeds
git config --global user.email "ci-bot@example.com"
git config --global user.name "CI Bot"
# Cache the token for pushes back to the remote
git config --global credential.helper store
```

## In CI

Commits fail with "Please tell me who you are" until user.email and user.name are set. Use --global on ephemeral runners so the identity applies to every repo in the job. For pushes, configure credential.helper or use a tokenized remote URL.

## 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
```

> `git rev-parse --abbrev-ref HEAD` returns the literal string `HEAD` on a detached checkout rather than a branch name. On GitHub Actions read `github.ref_name` instead; the git command cannot know what it was checked out for.

## FAQ

### git config Command: Configure Git in CI?

Fresh CI runners have no identity or credentials configured. Before a job can commit or authenticate, it usually sets user.email, user.name, and a credential helper.

### In CI?

Commits fail with "Please tell me who you are" until user.email and user.name are set. Use --global on ephemeral runners so the identity applies to every repo in the job. For pushes, configure credential.helper or use a tokenized remote URL.

---

Latchkey runs CI/CD that repairs its own failures. Agent entry points: https://latchkey.dev/agent.txt, https://latchkey.dev/openapi.json, https://latchkey.dev/llms.txt
