Reputation: 272
Doing a git clone
of my repository is a pain. While it really needs cleaning up given that it's 700MB zipped, why is that my .git folder at least 1GB in size? How do I reduce it?
Currently this repository has 165 branches and 13,478 commits. About 10 persons in our team maintain it. I've read about this guide but I really don't understand the repercussions of these actions, or how it would affect my colleagues' set up after the execution. Please help. Thank you.
Upvotes: 0
Views: 791
Reputation: 30858
The guide describes how to find and remove unnecessary files from the git repo. If you don't have any unnecessary files tracked by your git repo, this guide helps little.
If you need to clone and delete and re-clone the repo frequently, or if you need to make multiple clones of the repo, you could make a mirror clone first.
#make a mirror
git clone <url> --mirror -- <local_folder>
#make the clone for work
git clone <url> -b <branch> --reference=<path_of_mirror>
This way can save a lot of time and space. You could compare the size of the .git in a repo cloned via the mirror and the size of one cloned not via the mirror. Of course the mirror itself takes quite some space, but it's worth in this case. You could setup a crontab job to update the mirror via git fetch
if necessary.
If you are working with a specific published branch only, git clone <url> -b branch --single-branch
could save some time and space even without the mirror. But --single-branch is a feature of git after v1.7.x, so you may need to upgrade your git if necessary. With the old version not supporting --single-branch, we could use the following cmd instead,
mkdir work
cd work
git init
git fetch <url> <branch>:<branch>
git checkout <branch>
Upvotes: 1