Reduce git repository size

前端 未结 3 752
有刺的猬
有刺的猬 2020-11-22 11:00

I tried looking for a good tutorial on reducing repo size, but found none. How do I reduce my repo size...it\'s about 10 MB, but the thing is Heroku only allows 50 MB and I\

3条回答
  •  遥遥无期
    2020-11-22 11:29

    In my case, I pushed several big (> 100Mb) files and then proceeded to remove them. But they were still in the history of my repo, so I had to remove them from it as well.

    What did the trick was:

    bfg -b 100M  # To remove all blobs from history, whose size is superior to 100Mb
    git reflog expire --expire=now --all
    git gc --prune=now --aggressive
    

    Then, you need to push force on your branch:

    git push origin  --force
    

    Note: bfg is a tool that can be installed on Linux and macOS using brew:

    brew install bfg
    

提交回复
热议问题