How to understand the objects file in the .git folder?

my understanding of the principle of git is that every time git commit, it generates a tree object, a parent object (if not submitted for the first time), and a commit object. The top-level tree corresponds to the entire working directory, and there are blob and tree objects under the tree, all of which are a string of hash values pointing to the corresponding content. When a file changes, the snapshot will be saved again. If the file has not changed, the snapshot retained is still the last.

all the data is saved in objects, so don"t I have to generate a new file every time I submit (because the commit is different each time)? Then the content of the objects file of the whole project will become more and more after numerous submissions.

but I took a look at the objects in the project and there aren"t many files. Why is that? And as far as I understand it, each time commit generates only one file name in objects, which is the first two digits of each commit hash value, but actually generates three folders? And why is that?

< hr >

split line:
I built a new git repository locally, and there is only one txt file under the folder

clipboard.png

commitlog

clipboard.png


clipboard.png

treehashba65d8..hash:


clipboard.png
blobhashhash


clipboard.png
the last reference points to the contents of the file.

through the above operations, I personally understand as follows:
there are three objects in git. Tree, blob and commit, have passed the test. I think these three objects are not equal to each other. After submitting a commit, a commit object is generated. There is a top-level tree object under this commit object, and then there are tree objects or blob objects under the tree object. The lowest blob object is the content of the file

and git finds the corresponding file according to the hash value of these objects and records the status of each commit. Every time the commit is submitted, the changed file saves a new snapshot. The (hash), unchanged file still retains the original snapshot (hash) value.

Git
Apr.26,2021

Why are there not many files in objects?

the default format that Git uses when saving objects to disk is the loose object (loose object) format: each time a file is modified, in addition to retaining the old blob object, a new blob object with complete content is generated. From time to time, Git packages these objects into a binary file called packfile to save space and improve efficiency: Git when packaging objects , it looks for files with similar names and sizes, and saves only the differences between different versions of the file . Git does this when there are too many loose objects in the repository, or when the git gc command is manually invoked, or pushed to a remote server. After packaging, the objects in .git / objects are removed, and most of the remaining objects are not contained by any commit.

each time commit generates three folders in objects?

this has something to do with your file structure. The commit operation is bound to add the commit object, as well as the tree object that represents the root directory. If your modified file level is relatively deep, generate as many tree objects as you have.
each object is displayed as a folder.

or does it have something to do with your understanding? You update the problem, there is only a single file, in the root directory, then the file itself is a blob, it is under a tree (according to the supplement of your title, it is the root directory), and then there is a commit object. There are three of them.

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1e658e3-45b4d.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1e658e3-45b4d.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?