How to reduce git repo size on Bitbucket?

匆匆过客 提交于 2019-11-28 04:42:05

I've found that the easiest way to reduce the Bitbucket repo size if you are over the 2GB limit is to

  1. Create a branch on Bitbucket
  2. Delete that branch on Bitbucket

This should trigger Bitbucket to run git gc on the repo.

After conferring with Bitbucket technical support, I can now answer some of my own questions:

  1. Why did moving 450MB of files out of the repo only reduce the size of my local repo by 90MB? Something in the history got missed. I don't what exactly, but the filter-branch command missed something. I was able to successfully reduce the repo size by 450MB by running the utility BFG Repo-Cleaner.
  2. Why did even that modest reduction not get pushed to the remote repo on Bitbucket? It did, but Bitbucket support must then run git gc on their side. One can contact Bitbucket request and ask them to run git gc on a repo.
  3. How on Earth did the remote repo size jump from 973MB to 2.3GB? Unknown. Bitbucket technical support didn't have the answer to this one either.
  4. How do I fix it? Contact Bitbucket support. They can put a repository back into read-write mode so that you can push a smaller repository and they can run git gc on their end.

As I am sure those familar with got already know, but git stores your version history for files, so making changes and pushing files will not reduce your repo size.

There are still several ways to reduce repo sizes on bitbucket, GitHub, gitlab, etc. The best way is to delete branches, as that permanently deletes any files being recorded by that branch, as long as it is not being tracked by another. But you may want the latest files in that branch, so do the following:

  1. On local machine, create a duplicate repo. (Backup, so you don't lose info)
  2. Delete a branch that you want to move, or create a fresh version of. You can use --cached to delete remote branch.
  3. If you want to refresh branch, you can copy files into new branch and push.
  4. If you want to create new remote repo, you can do that too.

Depending on host, you may have to run special commands, but this should work in most cases.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!