What git init Actually Does
mkdir recipes && cd recipes
git init
Nothing about your files changes. git init creates exactly one thing: a .git subdirectory, right there next to
your files, containing everything git needs to track this project from now on.
Opening .git Directly
HEAD branches config description hooks info objects refs
Each of these is real and inspectable:
- HEAD — a plain text file. Right now it just says
ref: refs/heads/master — "the current branch is called master."
- objects/ — where every file's content will eventually live, content-addressed by its own hash. Empty until your first
git add.
- refs/ — where branch and tag pointers live. Empty until your first commit.
- config — this specific repository's own settings, separate from your global
~/.gitconfig.
Nothing Is Committed Yet
A fresh repository has no history at all — git init does not create a commit, does not touch your files, and
does not require a name or email to run. It only prepares the empty scaffolding that later commands (add, commit)
will fill in.
Your recipe collection needs a real home. This lab creates a project folder and runs git init inside it — then, instead of taking git's word for what just happened, opens the real .git directory it created and looks directly at HEAD, objects, and refs.
This is the single most important intuition to build early: a git repository is genuinely just an ordinary directory full of ordinary files, sitting on the same disk as everything else. Nothing about it is magic, remote, or hidden from you.
git init
Creates a new, empty .git directory in the current folder, turning it into a git repository. It touches nothing else — no commit is created, and no existing files are modified.
HEAD
A plain text file inside .git that points at whichever branch (or, later, commit) is currently checked out. Confirmed directly in this lab: cat .git/HEAD genuinely shows "ref: refs/heads/master" in a brand-new repository.
Takeaways
- git init creates exactly one thing: a real .git directory — it touches nothing else and creates no commit
- The .git directory is genuinely just files and folders — HEAD, objects, refs, config — all directly readable
- HEAD is a plain text file pointing at the current branch; a fresh repository genuinely points at refs/heads/master
- objects/ starts genuinely empty of real content, since nothing has been staged or committed yet
- A git repository has no external database or hidden service — deleting .git genuinely removes the entire repository