# git commit: Usage, Options & Common CI Errors

> git commit records staged changes as a new commit. Reference for -m, --amend, --no-verify, and the empty-commit and missing-identity errors in CI.

Source: https://latchkey.dev/learn/command-reference/git-commit  
Updated: 2026-06-25

git commit saves a snapshot of the staged changes to the repository history.

A commit is a permanent point in history. In CI you usually need a non-interactive message and a configured identity.

## What it does

git commit takes everything currently staged in the index and records it as a new commit with an author, committer, timestamp, and message.

## Common usage

```Terminal
git commit -m "Fix flaky test"
git commit -am "msg"        # stage tracked + commit
git commit --amend --no-edit
git commit --allow-empty -m "trigger build"
```

## Options

| Flag | What it does |
| --- | --- |
| -m <msg> | Set the commit message inline |
| -a / --all | Auto-stage tracked changes before committing |
| --amend | Replace the previous commit |
| --no-verify | Skip pre-commit and commit-msg hooks |
| --allow-empty | Permit a commit with no changes |

## Common errors in CI

Author identity unknown / "Please tell me who you are" - Git has no user.name/user.email. Set them in the job: git config user.email "ci@example.com" && git config user.name "CI". Also "nothing to commit, working tree clean" exits non-zero in scripts; guard with git diff --cached --quiet || git commit ...

## 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 commit: Usage, Options & Common CI Errors?

A commit is a permanent point in history. In CI you usually need a non-interactive message and a configured identity.

### What it does?

git commit takes everything currently staged in the index and records it as a new commit with an author, committer, timestamp, and message.

### Common errors in CI?

Author identity unknown / "Please tell me who you are" - Git has no user.name/user.email. Set them in the job: git config user.email "ci@example.com" && git config user.name "CI". Also "nothing to commit, working tree clean" exits non-zero in scripts; guard with git diff --cached --quiet || git commit ...

---

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
