Last active
January 25, 2019 19:01
-
-
Save adamwalter/3cf4bf68eac0392901a61a8c39a9ee7e to your computer and use it in GitHub Desktop.
Remove WordPress uploads (or any large files) from a Git repo
This file contains 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
# 1. Install BFG CLI | |
# https://rtyley.github.io/bfg-repo-cleaner/ | |
brew install bfg | |
# 2. Download BFG | |
# https://rtyley.github.io/bfg-repo-cleaner/ | |
# 3. Rename BFG's JAR file to 'bfg.jar' and move to ~/bfg.jar | |
# Test BFG by running empty "bfg" command | |
# 4. Add wp-content/uploads to your .gitignore | |
# 5. Remove uploads from Git | |
git rm -r --cached wp-content/uploads | |
# 6. Commit changes and push to remote | |
git commit -am "Removed uploads from repo" | |
git push | |
# 7. Re-clone your project as a bare repo in a different directory | |
git clone --mirror <your repo URL> | |
# 8. Run BFG | |
bfg --delete-folders uploads yourbarerepo.git | |
# 9. Move into the bare repo and purge the old files from the repo | |
cd yourbarerepo.git | |
git reflog expire --expire=now --all && git gc --prune=now --aggressive | |
# 10. Push your newly-cleaned repo to origin | |
git push |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment