Description
Stages every change in the working tree (modified, deleted and untracked files) and records a new commit on the current branch with the given message. This is the same as running grit add followed by a commit.
The message can be given as an argument or with -m. A message with several lines is recorded as is; its first line is the subject that grit log shows. A normal commit needs a message: without one, grit commit stages your changes and stops with an error.
With --amend, grit commit replaces the tip commit on the current branch instead of adding a new one. The new commit keeps the previous tip's parents and author; the committer and commit time come from your identity and GIT_COMMITTER_DATE as usual. If you omit the message while amending, the previous commit message is reused. Amending with no staged changes is allowed when the tree is unchanged (Git-compatible). You cannot amend on a branch that has no commits yet.
The author and committer come from the user.name and user.email settings (see grit config). To set the recorded time, use the GIT_AUTHOR_DATE and GIT_COMMITTER_DATE environment variables. On amend, the author line is taken from the commit being replaced, not from a fresh author identity.
When commit.gpgsign is true (or commit.gpgSign), grit commit signs the new commit object the same way Git does: OpenPGP and X.509 via your configured gpg/gpgsm program, or SSH via ssh-keygen -Y sign when gpg.format is ssh. Signing uses user.signingkey and the same gpg.* settings Git reads. grit merge and grit pick honor the same policy when they create commits.
grit commit fails when there's nothing to commit (except when amending with an unchanged tree), when HEAD is detached rather than on a branch, and when the index still has unmerged paths (for example after a merge conflict). Resolve conflicts, stage the result with grit add, then commit again.
When a merge is in progress (MERGE_HEAD is present) and every conflict is resolved in the index, grit commit records a merge commit with two parents (your branch tip and the merged tip) and clears merge state the same way Git does after git commit.
Options
| Option | Description |
|---|---|
<message> |
The commit message. |
-m, --message <message> |
The commit message, as an option. Use either this or the argument, not both. Optional with --amend (keeps the previous message). |
-a, --all |
Stage every change first. This is always what grit commit does; the option is accepted so that git habits like -am keep working. |
--amend |
Replace the tip commit on the current branch. |
JSON output
Pass --json for stable, scripting-friendly output:
| Field | Type | Meaning |
|---|---|---|
oid |
string | Full commit object id (40 hex chars for SHA-1) |
branch |
string | Short branch name (e.g. main) |
subject |
string | First line of the commit message |
changes |
number | Path changes vs the parent commit tree |
amended |
boolean | true when --amend was used |