> Canonical URL: https://codingcat.dev/course/odin-git-and-github-workflows/lesson/git-internals-commits-trees-and-staging-area

# Git Internals: Blobs, Trees, Commit Snapshots & the Staging Index | The Odin Project 2: Git & GitHub Engineering Workflows | CodingCat.dev Course

[🧶 The Odin Project 2: Git & GitHub Engineering Workflows](/course/odin-git-and-github-workflows)Section 1.1 · Lesson 1 of 2[Next Lesson →](/course/odin-git-and-github-workflows/lesson/branching-merging-and-rebasing-without-fear)

# Git Internals: Blobs, Trees, Commit Snapshots & the Staging Index

![Git Internals: Blobs, Trees, Commit Snapshots & the Staging Index Architecture Diagram](https://cdn.sanity.io/media-libraries/mlttp0BZbCpV/images/6f322a7529019b8447e7bff79290f47df2428d4a-1280x720.jpg?w=1920&h=1080&q=82&fit=max&auto=format)[@CodingCatDev62.5K / 100K Subscribers Goal](https://www.youtube.com/@codingcatdev?sub_confirmation=1)[Subscribe on YouTube→](https://www.youtube.com/@codingcatdev?sub_confirmation=1)[Watch on YouTube App ↗](https://www.youtube.com/watch?v=87ZFb2mT6jE&list=PLCOTCGP0a3VY)

## 1. The 15-Second Hook

Once you realize Git is just a directed acyclic graph of immutable snapshots and pointer files, you will never fear a detached HEAD or a bad reset again. Let's look under the hood of Git.

## 2. Architecture Mental Model (Visual Diagram)

On the left, running git add dot blindly commits secrets and messy WIP history. On the right, Git hashes file blobs into trees and commits, while git add dash p and git reflog give you surgical control.

## 3. Show Me the Code (terminal-git-internals.sh)

Copied! 🐾📄 terminal-git-internals.shtypescript

```
# Stage individual hunks interactively
git add -p src/mcp/transport.ts

# Inspect the underlying commit tree object
git cat-file -p HEAD

# Recover any unreachable commit via reflog
git reflog --date=relative -n 5
```

In our terminal workflow, git add -p stages specific code hunks interactively, git cat-file -p HEAD inspects the commit snapshot, and git reflog recovers any previous HEAD state.

## 4. Production Trade-Off Matrix

Comparing interactive hunk staging and reflog awareness against blind git add dot, you keep your commit history bisectable and never lose local work.

## 5. Verdict & AJ Pro-Tip

> AJ Pro-Tip: If you ever think you destroyed a branch with git reset --hard, run git reflog immediately: Git keeps every local commit hash for at least 30 days.

Master git add -p and git reflog first. Subscribe to CodingCat.dev and let's tackle branching and rebasing in Lesson 2.

✏️ Visual Architecture Diagram

## how this course connects together.

Follow AJ from first principles to production-ready architecture.

Let’s build it!✏️ Visual Diagram: The Odin Project 2: Git & GitHub Engineering Wor…✓ Good PatternVISUAL DIAGRAM[Diagram Walkthrough]Step-by-step diagram breakdown for The Odin Project 2: Git & GitHub Engineering Workflows: Git Internals: Blobs, Trees, Commit Snapshots & the Staging Index: start with Core Architecture & Implementation, implement The Odin Project 2: Git & GitHub Engineering Workflows, and ship to production.AAA Contrast Verified[Course Outline](/course/odin-git-and-github-workflows)

## The Odin Project 2: Git & GitHub Engineering Workflows

1/21

### Core Architecture & Implementation

- [1.1Git Internals: Blobs, Trees, Commit Snapshots & the Staging Index▶](/course/odin-git-and-github-workflows/lesson/git-internals-commits-trees-and-staging-area)
- [1.2Branching, Merge Commits vs. Interactive Rebase & Conflict Resolution](/course/odin-git-and-github-workflows/lesson/branching-merging-and-rebasing-without-fear)

@CodingCatDev on YouTube62.5K / 100K

Subscribe for new course lessons and architecture deep dives every week.

[Subscribe for New Lessons →](https://www.youtube.com/@codingcatdev?sub_confirmation=1)