Categories
guides troubleshooting

Git Repo Size

I had a private Bitbucket repo that was complaining I was over the soft limit of 1GB. I thought I had remembered cleaning up my commit history a long time ago to re-size this repo, but it was still showing in the Bitbucket/<user>/<repo>/admin that it was over 1GB.

The repo definitely wasn’t taking up that much space locally, so I was looking for another way separate from Bitbucket to determine the repo size. This made it sound like git count-objects -vH should also show me the size of the repo, but it was only 115MB – surely Bitbucket wouldn’t be miscounting the size by that much, right? I tried enabling the labs “Delete dangling commits when over size limit” as suggested in Bitbucket’s Reduce Repo Size docs, but after a day, the repo size still hadn’t changed.

Since I’m the only one using this repo, this is what I did:

  1. Clone the repo to my local machine
  2. Create a new empty repo on Bitbucket
  3. Edit origin in my .git/config of the local cloned repo to point to the new empty repo
  4. git push -u origin master to the new empty repo

The new repo appears to have my full accurate commit history, and Bitbucket shows the same repo size in its repo admin page as locally running git count-objects -vH.

Now I just need to update the .git/configs anywhere else I have this project to point to the new repo, and delete the old bloated one.

By bo.

I'm @boyEatsSteak in a lot of places. I have been wanting 🍕 for weeks. I like gadgets and technology and keeping notes and tips for my future self since all I can remember is that I forget things.