A commit is the most visible Git object. When people say "commit," this is what they mean. It contains:
- Tree SHA - a snapshot of all project files at that moment.
- Parent SHAs - one (typical), zero (root commit), or two or more (merge commit).
- Author - name, email, timestamp.
- Committer - name, email, timestamp. Usually the same as the author.
- Commit message.
To inspect one directly:
git cat-file -p HEAD
# tree 7e3f9a2b1c4d5e6f7a8b9c0d1e2f3a4b5c6d7e8f
# parent a1b2c3d4e5f6a7b8c9d0e1f2a3b4c5d6e7f8a9b0
# author John Smith <email@example.com> 1716817381 +0300
# committer John Smith <email@example.com> 1716817381 +0300
#
# README with project description
Snapshot, not a delta
A commit holds a reference to a tree, which is a full snapshot of the project at that point. It does not store a diff against the previous commit. The diff is computed on the fly by comparing the tree of this commit with the tree of its parent.
The SHA includes the parent
A commit's SHA is computed from its own content, which includes the parent's SHA. This means that if anything changes in an old commit, every descendant gets a new SHA. You cannot forge "one old commit while leaving everything after it unchanged."
This is the cryptographic integrity guarantee of Git history. The SHA of any commit is effectively a hash of all history leading up to it.
Author vs committer
The author wrote the change. The committer added it to the repository. They usually match. They diverge in these cases:
git cherry-pick- the original author is preserved; the committer becomes whoever ran the cherry-pick.git rebase- the author is unchanged; the committer becomes the current user.- Applying a patch from someone else via
git am.
To see both timestamps: git log --pretty=fuller.
Merge commit
A merge commit is a commit with more than one parent. Internally:
tree ...
parent <SHA of first parent>
parent <SHA of second parent>
author ...
committer ...
Merge branch 'feature' into main
The number of parents is not limited in theory (octopus merge). In practice, almost all merges have exactly two.