Reduce Repo Size on Bitbucket

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!

  • How to make GIT treat directory junctions as regular folders on Windows?
  • How to make fork changes reflect with the master when updated?
  • Does it make sense to create a branch for every developer?
  • Should I commit .testsettings and .vsdmi files to the repository?
  • Empty Git submodule folder when repo cloned
  • Gitosis alternative?
  • Xcode 4.3 how to merge storyboard changes from two developers using SVN?
  • Where are tag messages in Sourcetree
  • 2 Solutions collect form web for “Reduce Repo Size on Bitbucket”

    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!

    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!

    Git Baby is a git and github fan, let's start git clone.