Skip to content
LatchkeyLatchkey home

git commit: Usage, Options & Common CI Errors

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

FlagWhat it does
-m <msg>Set the commit message inline
-a / --allAuto-stage tracked changes before committing
--amendReplace the previous commit
--no-verifySkip pre-commit and commit-msg hooks
--allow-emptyPermit 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

Frequently asked questions

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

Related guides

References

Run this faster and cheaper on Latchkey managed runners - self-healing included. Start free → 30-day trial · No credit card