Reduce repository size
When you work with a DVCS repository cloning, pushing, you are working with the entire repository and all of its history. In practice, once your repository gets larger than 500MB, you might start seeing issues.
To learn more about the size limitations Bitbucket uses see, What kind of limits do you have on repository/file/upload size?
Ideally, you should keep your repository size to 100MB or less. To give you an example, 94% of Bitbucket customers have repositories that are under 500MB. Both the Linux Kernel and Android are under 900MB. In a perfect world, your ideal repository size should be less than or around 100MB. This page contains the following topics:
Finding your repository size
To check the relative size of your repository in Bitbucket click Settings (1), which should open the Repository details (2) page, then look for the Size (3) line.
Git Repository Size from the Command Line
For Git, you can use the
git count-objects -v command:
The size-pack value is the size of your repository when it is pushed to a remote server like Bitbucket. The size-pack value is in kilobytes. So, in the above example the repository is not even 1 MB.
Mercurial Repository Size from the Command Line
Mercurial does not provide a command specifically for find a repository repository size. You can use the bundle command to generate a compression of your repository and then see the size of the file:
Deleting Files and other Maintenance
Deleting unused files is a good way to reduce repository size. Remember deleting a file does not remove it from history. It does reduce your repository at is current version. Ever clone still contains the old file if you need to retrieve it. When looking at files to delete, consider the following:
- SQL dumps
- Large media assets
- Compiled versions of your applications
- Third party libraries and dependencies (jars, dlls, gem, etc.)
- Completely unneeded large files in history
Binary files are always candidates. DVCS systems are not good candidates for storing binary files. Consider hosting these on file hosting service such as Google Drive, Dropbox, or Carbonite.
You should also consider:
Split a Repository into Project Repositories
You can reduce your repository size by splitting a repository by code projects. This requires that you understand how your projects references each other. For example, if you have four projects that don't reference each other in one large repository, you split these up into four smaller repositories.
For a procedure on splitting a repository, see Split a repository in two.
Was this helpful?
Thanks for your feedback!