Warning: This process rewrites history. Teams beware!
I've found this useful to remove images from being stored within a Statamic website's repo and instead being backed-up to Digitalocean spaces. GitHub recommends this and I've followed this process a few times. Your mileage may vary.
1. Check current size of repo (on dev server or locally):
- Nav to repo
- Check repo size:
git count-objects -v
- Take a screenshot
2. Install newren/git-filter-repo
sudo apt install git-filter-repo
3. Add paths to remove to .gitignore
4. Run command to remove directories or files from Git's history:
- Nav to repo
- To remove this directory: "/public/main/", run
git-filter-repo --invert-paths --path public/main/ --force
5. Check new size of repo
git count-objects -v
- This should be smaller than before.
6. Commit and force push
git add .
git commit -m "remove images assets from repo"
git push --force --all
7. Update other repos / enviroments
- Login to other servers or tell colleagues to run
git pull --rebase