Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to optimize a remote GIT repo - mainly Heroku

Tags:

git

github

heroku

Recently I've added huge files to my local repo and pushed those files outside to other repositories. After I realized that, I did some googling on the topic and removed those files entirely using git reset. I also did some other things to optimize the repo (git gc, repack). Now my local copy of the repo is below 100MB down from over 400MB. The problem is though, that my repo on heroku site is still listed as 400MB, and I am not really sure if theres something I should to, to reflect all the changes into remote repo?

like image 493
mdrozdziel Avatar asked Feb 26 '23 21:02

mdrozdziel


1 Answers

Like with the local repo, git gc is the operation which will clean out all the loose objects (like the blobs for your files which are no longer part of the history). When you have access to the remote, you can do this directly. If there's absolutely no way to do that, then you're stuck waiting until one of your pushes triggers git gc --auto. That's guaranteed to happen eventually, so unless there's actually a problem with the repo taking 400MB (e.g. paying more for hosting), it's not really an issue. Anyone fetching/pulling/cloning from the repo is just going to get what they need to get, the 100MB.

I believe that github also periodically runs git gc on repositories; I don't know if Heroku does anything like that.

like image 75
Cascabel Avatar answered Mar 01 '23 08:03

Cascabel