Home > Software engineering >  Git Repo Too Large Even After Removing .git Directory
Git Repo Too Large Even After Removing .git Directory

Time:03-10

I have a repo that is 3.6GB. In order to clean this up, I removed all large files then pushed the deletions to the remote git repo hosted in BitBucket. After this, I deleted my .git directory on my local. I did git init and pushed all the existing files to the existing remote repo.

Despite this, BitBucket is still telling me that the repo is too big? I looked at various solutions on the internet but all of them seem to be referencing BFG and other cleaning tools. I was under the impression that all of these scripts just clean up .git. By deleting .git I was hoping that any unnecessary files would be deleted but that's clearly not the case.

If my .git directory is not the issue, I was wondering what else it could be?

CodePudding user response:

Deleting your local .git directory doesn't delete the remote Git directory, which will still contain all the old stuff, including the earlier history of the repo and every version of every file ever committed to it.

If you delete all references such that the entire history of the repository is no longer reachable from any existing branch, then Git should garbage collect it eventually, possibly around two weeks if I recall correctly. If you have shell access, you can run git gc yourself.

Your better bet is to delete and recreate the remote repo, if you truly don't want any of the project's history.

  • Related