I have a web project which I am migrating, my main concern is that the .git file is > ~30MB. (which is in fact bigger than any other directory on the project)
Is there a way of reducing .git size?
Note: my repo is on bitbucket
Before I get into ways to reduce the repository size... 30 megs is still rather small. AFAIK Bitbucket's limit is 1 or 2 gigs per repository. So ask yourself why you're concerned?
Usually large repositories are the result of committing large, binary files like videos, high-quality images, or archives (which are better committed unpacked). Since they're binary and hard to diff, each change to a binary file might store a whole new copy.
There's two tools to deal with this, and fortunately the work well together. The first is git-lfs
, Git Large File Storage. This is the best of both worlds. You can commit large files without bloating the repository, they're instead stored separately on BitBucket. BitBucket has some limitations with git-lfs
you should be aware of.
That's great going forward, but what about reducing the repository size now? For that there's the BFG Repo Cleaner. This tools lets you easily remove files of a certain type or over a certain size.
Put them together and you have BFG support for git-lfs
. You can use the BFG to move files to LFS rather than simply delete them.
But, again, unless you have special bandwidth or space concerns for your developers, a 30 meg repo is fine. Keep this knowledge for when you're pushing hundreds of megs.
As mentioned in the comments, the size of your .git
folder is essentially a non-issue. Due to its role in storing the entire history of your project, it will almost automatically become the largest folder in your project's directory structure after any reasonable length of time.
Besides that, 30MB is positively tiny. Unless you're doing development on a machine from the 1980s (at which point you could probably sell it on eBay as an antique and use the money to buy a new computer), you're more likely to be struck by lightning than experience issues from it.
.git
folder contains the contents of every file in the project, including a history for each file. It generally should be one of the larger (if not the largest) folders in your project..git
folder that is about 14 GB. Bitbucket handles that just fine.