How does git store large files across many records?

So, I started using it gitfor a while and I understand how it works gradually. One of the main points that I realized is that it creates a snapshot every time a new commit is made. Of course, a snapshot will only contain modified files and pointers to an immutable file.

According to Pro Git & sect; 1.3 Getting Started - Git Basics

Each time you make or save the state of your project in Git, it basically takes a photo of how all your files look at the moment, and saves a link to this snapshot. To be effective, if the files have not changed, Git does not save the file again - only a link to the previous identical file that it already saved.

But let's say I have a really big file, for example. 2GB text file. And I change this file 10 times and therefore make 10 commits per day, does that mean I now have 10 2 GB files on my computer? This seems ineffective to me, so I think it might not be so.

Can someone clarify what will happen in this scenario?

+4
source share
2 answers

Short answer: "Yes, now you have 10 files on 2 GB." However:

  • Files under commit are saved as blob objects, and all git objects (drops, trees, commits and annotated tags) are stored internally in zlib deblated format. Thus, a 2 GB text file is actually a significantly smaller object.

  • "" ( ) "". git pack-objects git repack, git " " (git gc). - . .

, , git , ( , 2 .tgz ). , , , -, . : git -annex git -bup. . git.

+7

.

(24 ) . .git 216 . git , .

. .git 356 ..git/objects 132 .

132K    ./.git/objects/8d
132K    ./.git/objects/f7

git gc 68 .

, , git .

+2

Source: https://habr.com/ru/post/1538957/


All Articles