How does git actually work? (Internal working)
As developers, git is an internal part of our life so have you wondered what does the internal of git looks like? Is it crazy complex? Its crazy simple, here’s how it works.
The .git folder is created when you type git init in your project folder. Although you cannot see it, to check if it exists, go to your current folder and type ls -a and then you see it.
What’s inside .git folder ?

You know git has option to create many branches, so where are these branches stored?
Its inside .git/refs/heads/ . Here you find all the branches of your project folder
So what about the commit messages and actual changes? where are those stored?
It’s inside .git/objects/
Git doesn't store "changes" (the difference between version A and B); it stores Objects
Commit Messages: Stored inside Commit Objects. These objects contain the author, date, and the message you typed.
Actual Content: Stored inside Blob Objects. Each blob is a compressed version of a file at a specific point in time.
The Folder Structure: Stored in Tree Objects, which link filenames to the blobs.
Woah…. Git uses Hash to ensure integrity. How?
Since git maintains and tracks changes to a file. It needs to ensure no changes are missed by it. When you write git commit , it takes up all your data ( no matter the size) and uses it to generate a hash(a unique 40-character string of letters and numbers). Also, every commit contains the hash of its parent(ie the previous commit) which is a linked list. So the tracking of commit history and changes is easy and if anyone tries to change a previous file, the hash is changed and git notices it.
