Skip to content
Latchkey

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

Related guides

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