Skip to content

Instantly share code, notes, and snippets.

@mockdeep
Created January 24, 2012 07:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mockdeep/1668698 to your computer and use it in GitHub Desktop.
Save mockdeep/1668698 to your computer and use it in GitHub Desktop.
# first clone your repo
git clone path/to/my/repo path/to/clone
# do some initial housecleaning:
rm -rf .git/refs/original/
git reflog expire --expire=now --all
git gc --prune=now
git gc --aggressive --prune=now
# note the repo size:
du
# find the commits where the file was removed:
git rev-list -n 1 HEAD -- ./tapjoyads/data/GeoIPCity.dat
git rev-list -n 1 HEAD -- ./tapjoyads/data/GeoLiteCity.dat
# check out the file from that commit:
# (you may need to remove GeoIPCity.dat from .gitignore)
git checkout <commit hash>^ ./tapjoyads/data/GeoIPCity.dat
git checkout <commit hash>^ ./tapjoyads/data/GeoLiteCity.dat
# notice the carat -------^
# commit the files:
git commit # add a message
# purge it! (these will take a long time...)
git filter-branch --index-filter 'git rm --cached --ignore-unmatch ./tapjoyads/data/GeoIPCity.dat' -f
git filter-branch --index-filter 'git rm --cached --ignore-unmatch ./tapjoyads/data/GeoLiteCity.dat' -f
# and do some gc:
rm -rf .git/refs/original/
git reflog expire --expire=now --all
git gc --prune=now
git gc --aggressive --prune=now
# and find out if it was worth it:
du
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment