My GIT has turned into a monster. It takes almost 70 minutes to clone it. Is it possible to trim the repository and archive old commits that are no longer relevant? I don't want to delete them though. What can I do to minimize the size of my git repository?
-
Are you storing binary files in the repository or only code files? – William Moore Jul 19 '15 at 13:36
-
Size and cloning method would help. – jthill Jul 19 '15 at 18:47
2 Answers
See "How to reduce disk space usage in a large repository?" for the main options.
In your case, I would advise to split a repo history, but also check if you can split some of the subfolders into their own git repos (and reference them through submodule gitlink entries).
Make sure that no binaries (especially if they can be re-generated from the sources) are stored in the repo history.
Apart from getting rid of unnecessary files from the repository as VonC pointed out, there are two possibilities that come to my mind:
- First one would be to clone only the necessary branches, since git 1.7.10 you could do something like:
git clone URL --branch branch_name --single-branch [folder]
This could be useful if you have many branches and divergences in your repository, otherwise there won't be much gain.
- An alternative to this would be a shallow-clone, which basically is a partial clone of your repository. You could use it like this:
git clone --depth [depth] remote-url
There were many limitations with shallow-clone as not being able to fetch or push to the repository, but apparently some of them have been overcomed in 1.9 version.
You could also use the filter-branch option to rewrite some history but that would mean a lot of manual effort if your repository is very big, and everybody would need to clone repo again once you are done with it.

- 1,754
- 1
- 14
- 22