> For the complete documentation index, see [llms.txt](https://strctr.gitbook.io/programming/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://strctr.gitbook.io/programming/02-tools/git/03-git-data-model.md).

# 03. Git Data Model

Git data model consists of:

* In Git, the contents of files are stored as **blobs**.
* Directories in Git basically correspond to **trees**. A tree is a simple list of trees and blobs that the tree contains, along with the names and modes of those trees and blobs.
* The **commit** is very simple, much like the tree. It simply points to a tree and keeps an author, committer, message and any parent commits that directly preceded it.
* A **tag** is an object that provides a permanent shorthand name for a particular commit. It contains an object, type, tag, tagger and a message.
* **References** are simple pointers to a particular commit, something like a tag, but easily moveable. Examples of references are *branches* and *remotes*. A branch in Git is nothing more than a file in the `.git/refs/heads/` directory that contains the SHA-1 of the most recent commit of that branch.

All of these types of objects are stored in the **Git Object Database**, which is kept in the **Git Directory** (`.git`). For particular example git database will be looks like this:

![](/files/-M6fs5jSVMoIj2y0hsl0)

Git gets the initial SHA-1 of the starting commit object by looking in the `.git/refs` directory for the branch, tag or remote you specify. Then it traverses the objects by walking the trees one by one, checking out the blobs under the names listed.

![](/files/-M6fsBMFGExaADtnRkaA)

In computer science speak, the Git object data is a directed acyclic graph. That is, starting at any commit you can traverse its parents in one direction and there is no chain that begins and ends with the same object.

The basic data model looks something like this:&#x20;

![](/files/-M6fsJ7yJzRgqKyDgChd)

For several commits model can be expanded:&#x20;

![](/files/-M6fsLjiKgM_jeP46aXF)

The **history** in Git is the complete list of all commits made since the repository was created. History is the one of the most significant artefacts produced by git.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://strctr.gitbook.io/programming/02-tools/git/03-git-data-model.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
