Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Does git smartly handle a zip archive in which only one of the files changes regularly?

In one of my git projects, I have a zip file which bundles a set of java libraries. The zip file is 4.5MB and contains 11 files. Only one of the contained libraries is changed regularly, the one that I'm working on (which is in the order of 50KB). The other libraries are static.

It would be great if git smartly only changes this small change in the zip file, and not replaces the whole zip file with every commit. Else, my git repository will grow very rapidly.

When I have updated my library and have recreated the zip file, and commit+push the changes, I notice that git writes objects in the order of <100KB to the server, like "Writing objects: 100% (58/58), 77.64 KiB, done.". So it looks like git smartly sends only the changed part of the zip, and not the whole 4.5MB zip file again and again.

Is it indeed the case that git smartly handles zip files?

like image 496
Jos de Jong Avatar asked Apr 02 '12 08:04

Jos de Jong


1 Answers

Git knows how to handle diffs in binary files, so if a few files have changed in the zip it won't store the whole file at each commit.

As a side note, I wouldn't recommend storing zip in your repository, as it's likely to be an artifact (i.e. compilation result) of your code, unless it is a repository storing only your artifacts.

like image 159
CharlesB Avatar answered Sep 24 '22 15:09

CharlesB