Inside Git :How it works and the role of .git folder
Before get into the how git works,let’s first understand what is git?
Git:-
Git is a distributed version control system (VCS).
Git is used to track live changes inside the code,for collaboration.
It is termed as VCS because it allows a multiple people to work on the same branches.
Now intialize a git into your project with command:
git init
With git init command .git folder created in your project ,we should not manipulated this folder because it is maintained by itself.
.git folder:-
The .git folder is a hidden directory which contains metadata and history of your project.
It stores everything commit history, file versions, tags and branches.
Deleting this folder means losing your local project’s entire history.
Git Objects:-
A fundamental building block of the git repository, used to store data as a specific type (blob,tree, commit or tag)
Four main git objects:-
Blob:-
Stores the raw content of a file.
It does not store metadata like filename,date and author.
It only contains the files data at a specific point in a time.
If two files have identical content,git stores only one blob.
Tree:-
A tree is an object that represents a folder.
Names of files
Names of folder
Hash
Commit:-
A commit is a saved snapshot of your project at a specific time.Identified by unique ID i.e Hash.
Author
Timestamp
Commit message
Tag:-
In git, a tag is uesd to mark specific commit-most commomally to label releases like v1.0, v2.1.3

How git track changes:-
Git tracks changes saving snapshots of files, not by tracking line-by-line edits.
* On the next commit:-
Git takes snapshot of all files.
If a file changes,git stores a new version.
Each commit links to the previous one.
Conclusion:-
Git is a distributes version control system which tracks the live changes inside the code, collaborate efficiently,git tracks changes saving snapshots of files, not by tracking line-by-line edits.Git compares each commit to previous commit to track the change. It works by storing the snapshots of project inside the .git folder which is a hidden directory which uses a core objects like blob,tree and commit.