Frage

The git repository of my current project, containing source code and image files, measures around 1.2 gigabytes. But the the actual files of all branches are only around 205 megabytes in size.

I am a beginner with git and I guess that the huge repository size is caused by moving the image files around in the repository. Since git doesn't catch moved files, it stores the image at its old location in the history along with the image at its new location. I am not sure if that could cause such a big overhead.

Anyway, how can I reduce the repository size without loosing the history of source code files? It is acceptable for me to loose the history of image files.

War es hilfreich?

Lösung

Git does not store extra copies of files that are moved or copied. If the content is the same, the only thing that git stores is the new tree structure(s).

Details on the Git object model: http://git-scm.com/book/en/Git-Internals-Git-Objects

git gc is the common way to do regular house-keeping on a repository, give it a shot and see if your repository shrinks.

If that doesn't do it (sometimes git gc will choke, particularly on repositories with a lot of binary data), try using git repack. It'll often take quite a while, but it should shrink the repository, if at all possible. Try this:

git repack -adf --window=250 --depth=250 --window-memory=1024M

Note the --window-memory option; if your machine has enough memory you might just get away without using this option, but if not it should prevent git repack from failing from running out of memory. In my experience, setting it to half or less of the available memory usually works fine.

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top