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.
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.
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>>
…