I used git-filter-repo to remove several large binary files from my git repo after migration from SVN. Now, I have to add few selected files back and was wondering what will happen to the git repo size if I add the identical 3.14MB binary file to 5 branches: Does git detect that the file has the identical hash? Does repo size grow by 3.14MB, or by 5x3.14MB?
And, similar question for text files: Does git detect if I add a copy of a text file to a different old/existing branch? What if it is slightly modified?
If the file is bit for bit 100% identical, it will only exist as blob once in Git's object database.
You can manually run
git hash-object path/to/fileto verify yourself.But changing a single bit in the file could cause it to require twice the size (each version is stored separately as full snapshot. Delta compression can help, but it's not guaranteed to work for every type of file/blob.
git gcruns garbage collection and repacks the objects in your object database).Further reading: How does Git store files?