CodeBlanks Logo Icon CodeBlanks

Object database

Learn blob, tree and commit objects.

What Is the Git Object Database?

Git stores file contents and history information in its object database. This database is located in .git/objects. Git objects are identified by hash values based on their contents; objects with identical content can have the same identity.

.git/objects/
├── 1a/
├── 4f/
└── info/

Objects are usually stored in compressed form and read by Git when needed.

Blob, Tree, and Commit Objects

A blob object stores file content, while a tree object represents directory structure and links between filenames and objects. A commit object contains a reference to a tree, author and date information, a commit message, and links to parent commits when present.

Commit
  └── Tree
       ├── Blob (index.html)
       └── Blob (style.css)

This structure allows Git to reconstruct a project's file tree and history at a particular point in time.

Practice Find the Object ID of File Content

Calculate the hash of a file's content without writing it to the Git object database. Do not use the -w option with hash-object; the goal is only to display the object ID.

Starter code

terminal
# Dosya içeriğinin hash değerini hesapla

Expected output

8f3a2b1c4d5e6f708192a3b4c5d6e7f8091a2b3c

Questions and answers

Review the lesson questions together with their answers. To test yourself, solve the lesson interactively.

1 Which object type stores the raw content of a file in Git's object database?

  • Tree
  • Commit
  • Ref
  • Blob Correct answer

Explanation: A blob object stores file content; it does not independently store the filename or directory structure.

2 The Object That Represents Directory Structure

Question
Blob dosya içeriğini saklar. Dizin yapısını ve dosya bağlantılarını temsil eden nesne ise tree nesnesidir.____
Answer
Blob dosya içeriğini saklar. Dizin yapısını ve dosya bağlantılarını temsil eden nesne ise tree nesnesidir.tree

Explanation: A tree object stores directory entries and their links to blob or other tree objects.

3 Git Object Types

Term Meaning
Blob Stores file content
Tree Stores directory and file links
Commit Records a project snapshot
Hash Identifies an object by its content

All lessons in Expert