1

I've realised my repo is coming in at just over 1GB, it seems my .git folder weighs in at 800MB. Why is this and what are the right ways to go about reducing this?

Any help is appreciated. Thanks in advance!

realph
  • 3,941
  • 12
  • 38
  • 93
  • Do you have large PSD files in it? Have you tried these answers yet: https://stackoverflow.com/questions/15694034/why-is-my-git-file-huge, https://stackoverflow.com/questions/5613345/how-to-shrink-the-git-folder , https://stackoverflow.com/questions/1029969/why-is-my-git-repository-so-big – jojo May 14 '15 at 01:10
  • Also, which folder of .git is biggest? – jojo May 14 '15 at 01:11
  • @jojo The objects folder. Looks like I was an idiot and some pretty big zips were added to my repo many commits ago. – realph May 14 '15 at 01:22

2 Answers2

0

Your .git folder is bloated somehow, most likely due to git history or old assets:

Source: http://blogs.atlassian.com/2014/05/handle-big-repositories-git/

  • They accumulate a very very long history (the project grows over a very long period of time and the baggage accumulates).
  • They include huge binary assets that need to be tracked and paired together with code.
  • Both of the above.

Here are some ways to remedy it:

Shadow Clone Method

Run git clone --depth <# of commits of history> <remote-url>.

Filter-branch Method for large binary files or old assets like old PSDs

Run something like git filter-branch --tree-filter 'rm -rf /path/to/spurious/asset/folder' HEAD. Beware filter-branch can rewrite the history of your commits, thus others who have an older version of your repository will need to clone it again. Warn your coworkers before you do this method!

There are more methods and alternative ways in the atlassian link above.

EDIT: Make sure to create a backup repo of your original repo just in case!

jojo
  • 1,043
  • 1
  • 14
  • 32
0

Instead of using git filter-branch manually, I highly recommend using the BFG (https://rtyley.github.io/bfg-repo-cleaner/), since it is much faster and can help you get rid of larger files. The instructions on that page are very easy to follow.

However, note that the BFG removes large files from your .git history only if they are NOT currently committed to your repo. Before you use the BFG, you should

git rm --cached FILENAME

any large files (like large zips as you mentioned above). If you don't need them anymore, you can just delete them completely. And remember to add *.zip to your .gitignore!

mprat
  • 2,321
  • 12
  • 31