Created
September 5, 2015 03:29
-
-
Save jefffederman/cd60c4cda27fde87a015 to your computer and use it in GitHub Desktop.
How I removed ~190MB of image files from my Git repo
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
app/assets/images/exercises/**/*. | |
exercise*frame_*.jp{g,eg} | |
*_thumb.jp{g,eg} | |
1. Get list of unwanted files | |
$ git log --raw |awk '/^:/ { if (! printed[$6]) { print $6; printed[$6] = 1 }}'|while read f;do if [ ! -f $f ]; then echo Deleted: $f;fi;done | |
SEE http://stackoverflow.com/questions/7336252/how-to-remove-all-files-in-a-git-repository-that-are-not-in-the-working-director/7399719#7399719 | |
2. Use sed to remove ones that don't fit pattern | |
3. Get mirror of repo | |
`git clone --mirror git://example.com/some-big-repo.git` | |
3. Use repo cleaner | |
https://rtyley.github.io/bfg-repo-cleaner/ | |
E.g., java -jar ~/Downloads/bfg-1.12.4.jar --delete-files "*_thumb.jp{g,eg}" some-big-repo.git | |
4. Push to new repo | |
5. Clone that repo | |
6. Add heroku remote | |
7. heroku:repo reset -a appname | |
8. Push your new repo to heroku |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment