Created
November 20, 2014 16:49
-
-
Save FlicAnderson/bee711ffc098ec2849b9 to your computer and use it in GitHub Desktop.
How to run BFG to slim large repos
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# How to run BFG to slim large repos: howToBFGrepo.sh | |
# ==================================================== | |
# (20th November 2014) | |
# Author: Flic Anderson | |
# Written using Git Bash v1.9.2; Windows 7; BFG Repo-Cleaner 1.11.8 | |
# ~ standalone script to use in bash | |
# AIM: To remove stupidly large files from a repo that you've had in there for some time, | |
# .... figure out whether they are all over a certain size (eg. 500K) and that they are ALL deletable. | |
# .... delete what you can, and commit each deletion so it's recorded. | |
# Follow instructions & run the following commands from the repo location (e.g: flicanderson@comp ~/fufluns (master)) | |
cd ~/fufluns | |
# download the bfg.jar file from http://rtyley.github.io/bfg-repo-cleaner/ | |
# place it somewhere nearby (but not in the repo, or it'll be removed) | |
# put it somewhere like "~/New\ folder/bfg-1.11.8.jar" | |
# clone with mirror the repo in question (after backing it up elsewhere) into the main repo folder (~/fufluns/) | |
git clone --mirror https://github.com/FlicAnderson/fufluns.git | |
# this creates a "fufluns.git" file in the repo directory (eg. ~/fufluns/fufluns.git) | |
# bring up bfg; shows the help and usage details. | |
# first section is location of java.exe (usu program files), then " -jar " then location of bfg .jar file | |
C:/Program\ Files/Java/jre1.8.0_25/bin/java.exe -jar ~/New\ folder/bfg-1.11.8.jar | |
# edit the last command to clean out all files over a certain size (eg 1M, 500K, etc) | |
C:/Program\ Files/Java/jre1.8.0_25/bin/java.exe -jar ~/fufluns/bfg-1.11.8.jar –strip-blobs-bigger-than 500K fufluns.git | |
# this removes all FILES over 500KB, WHICH HAVE ALREADY BEEN REMOVED AND COMMITTED. | |
# If you haven't removed them all yet, it'll leave them alone and list them in an output file in a report | |
# folder it creates. Open it, find the files, delete them and commit their deletion. If you do this, ensure you then: | |
# git add fkds;ajfd.jpg | |
# git commit -m "kljkhjfds" | |
# git push origin master | |
# DELETE THE FUFLUNS.GIT FOLDER | |
# git clone --mirror https://github.com/FlicAnderson/fufluns.git | |
# then re-run the bfg command above | |
# move to the mirror clone .git (prompt should show your location as "~/fufluns/fufluns.git (BASE: master)") | |
cd ~/fufluns.git | |
# update reflog | |
git reflog expire --expire=now --all | |
# carry out garbage collection for all redundant things changed by bfg | |
git gc --prune=now --aggressive | |
# then push the changes! | |
# this doesn't need "origin master" as you're currently in the mirror .git | |
git push | |
# then delete the ~/fufluns folder | |
# then clone down a fresh copy | |
git clone https://github.com/FlicAnderson/fufluns.git | |
# The github repo size reported online via Settings>Repositories won't be accurate for a while | |
# this is due to their garbage collection happening at a later/different time. We ran ours manually. | |
# Enjoy your smaller, cleaner repo! |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment