What is inside the .git folder and how does it relate to version control?

Git was my valentine this year. I finally went deep inside .git and got to know it a lot better.

Pravat Pandey
5 min readFeb 23, 2021

If you are like me, you find it easier to learn new things if you already know its fundamentals. With this article, we will have a deeper understanding of how git works under the hood.

The .git folder

When we initialize a git repository, a .git folder gets created. Git uses this folder to perform its version control. Git takes snapshots of the state of all the files and stores them as binary in the .git/objects folder.

Git storing snapshots of all files in the project (instead of storing delta changes between each files which other VCS do.)

Objects

Files and their objects

If a file has been committed at least once, it is considered a tracked file.
Every time we stage changes of these tracked files, a new object gets created. These objects created for files are said to be of type blob.

The blob objects get stored as a SHA1 hash of the contents of the file. We can use the command git hash-object <<path_to_file>>

--

--

Pravat Pandey
Pravat Pandey

Written by Pravat Pandey

I am a computer science student with lots of interests and a goal to be the best at all of them.

No responses yet