Chapter 1.4

Inside .git/

Git is famously described as a "leaky abstraction." If you don't know what's happening under the hood, it feels like magic—until it breaks. Let's lift the hood.

The File Tour

When you type git init, Git doesn't build a complex database daemon. It literally just makes a hidden folder named .git/, and creates a few empty text files inside of it.

Explore the directory below. Click on the files and folders to see what they do.

Directory Tree
.git/
Select a folder or file to explore

Plumbing vs Porcelain

Normally, you type commands like git commit or git branch. These are called Porcelain commands—they are easy to use and look nice.

But behind the scenes, Porcelain commands are just scripts that run lower-level Plumbing commands to modify the files you just explored above!

The Mapping

git branch my-feature→ creates file in refs/heads/
git add file.txt→ writes blob to objects/
git checkout dev→ modifies the HEAD file

Is it safe to delete the .git folder?

If you delete the .git/ folder, you lose the entire history, all branches, and all commits of your project. It ceases to be a Git repository.

However, your Working Directory (the actual `.js` or `.html` files in your code editor) will remain perfectly intact. You just won't be able to time-travel anymore.