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
| 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 ...
Related guides
git add: Usage, Options & Common CI Errorsgit add stages changes for the next commit. Reference for -A, -p, --update, and the pathspec and ignored-file…
git push: Usage, Options & Common CI Errorsgit push uploads local commits to a remote. Reference for -u, --force-with-lease, and tags, plus the rejected…
git config: Usage, Options & Common CI Errorsgit config gets and sets Git configuration at system, global, and local scope. Reference for --global, --get,…
git reset: Usage, Options & Common CI Errorsgit reset moves HEAD and optionally the index and working tree. Reference for --soft, --mixed, --hard, and ho…