The atom of git commit. Take a tree SHA, get a commit SHA.
git commit-tree creates exactly one commit object in the object database from a given tree OID, optional parents, and a message. It is the single atom that git commit orchestrates around — porcelain just stages, writes a tree, calls commit-tree, and updates a ref.
Pure object-DB writer. Input: a tree OID, zero-or-more -p parents, a message. Output: a commit object's SHA on stdout. It does NOT update HEAD, it does NOT touch any ref, and it does NOT consult the index. To 'do a commit by hand': write-tree -> commit-tree -> update-ref refs/heads/branch <new-sha>.
git commit-tree <tree> [(-p <parent>)...]
[-S[<keyid>]] [--no-gpg-sign]
[(-m <message>)...] [(-F <file>)...]
[< message-on-stdin]| Flag | What it does |
|---|---|
<tree> | Required. The tree OID whose snapshot this commit will point at — typically from git write-tree. |
-p <parent> | Add a parent commit OID. Repeatable: zero parents = root commit, one = normal, two-or-more = merge. |
-m <msg> | Commit message. Multiple -m become separate paragraphs (matching git commit -m). |
-F <file> | Read the commit message from <file>. Use - to read from stdin. |
-S[<keyid>] | GPG-sign the commit; optional <keyid> picks a key. The signature lives in the commit object header. |
--no-gpg-sign | Override commit.gpgSign=true for this one invocation. |
write-tree then commit-tree then update-ref.TREE=$(git write-tree); echo "msg" | git commit-tree $TREE -p HEADgit commit-tree $(git write-tree) -m 'initial'git commit-tree $TREE -p main -p feature -m 'merge'SHA=$(git commit-tree $TREE -p HEAD -S -m 'signed'); git update-ref refs/heads/main $SHAgit update-ref -m '<reason>' refs/heads/<branch> <new> <old> so the reflog records the move.GIT_AUTHOR_ and GIT_COMMITTER_ env vars when scripting to keep author/committer metadata deterministic.gc will eventually delete them. Always update-ref promptly.-p HEAD produces a root commit (zero parents), severing history without warning.write-tree after staging, you commit a stale snapshot.Hit each option, then Check answers. Score is recorded; Next is always open.