linuxlab.io
Tutorials▾
  • Linux & networking
    File system, processes, TCP/IP, BGP and OSPF
    →
  • Terraform & IaC
    HCL, state, plan/apply on a LocalStack sandbox
    →
  • Git & GitHub
    Object model, plumbing, branching, GitHub Actions
    →
All tutorials →
PricingAboutSign inCreate account
/
Intro
Lessons
Footer
linuxlab-TutorialsPricingAboutPrivacy & cookies
Copyright © 2026 LinuxLab. All rights reserved.
linuxlab.io
Tutorials▾
  • Linux & networking
    File system, processes, TCP/IP, BGP and OSPF
    →
  • Terraform & IaC
    HCL, state, plan/apply on a LocalStack sandbox
    →
  • Git & GitHub
    Object model, plumbing, branching, GitHub Actions
    →
All tutorials →
PricingAboutSign inCreate account
/
  • Introduction
  • Chapters
  • How it works
  • Lessons
  • Knowledge base
  • Interview prep
home/git/kb/Object model/commit

kb/objects ── Object model ── intermediate

Commit

A Git object: a snapshot of the entire project (via a tree) plus metadata including author, committer, date, parents, and message. The SHA of a commit includes the parent's SHA, which makes history cryptographically linked.

view as markdownaka: git-commit, commit-object

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:

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

§ команды

bash
git cat-file -p HEAD

Show the raw content of the HEAD commit

bash
git commit-tree <tree-sha>

Create a commit from a tree (plumbing)

bash
git log --pretty=fuller

Show both author and committer dates

bash
git log --pretty=format:'%H %an %s'

Custom history output format

§ см. также

  • treeTreeA Git object that holds the listing of one directory: entries of the form `(mode, type, SHA, name)`. It references other tree objects recursively for subdirectories.
  • blobBlobA Git object that stores the content of a single file. Just bytes, no name, no permissions, no date. The filename lives in the `tree`, not in the blob.
  • tagTagA named pointer to a commit. Two kinds: lightweight (a file with a SHA in `refs/tags/`) and annotated (a separate object in `objects/` with author, date, and optional signature). For releases, use annotated.
  • sha1SHA-1 in GitThe 40-character hash Git uses to address objects. Computed from content with a type prefix. Broken cryptographically in 2017 (SHAttered), but still the default in Git as migration to SHA-256 moves slowly.
Footer
linuxlab-
Copyright © 2026 LinuxLab. All rights reserved.
Tutorials
Pricing
About
Privacy & cookies