remove git cruft

My original inspiration for this post came from steven ostermiller's blog post that no longer exists from my last check in May, 2024.

git
Copy this post

inspiration #

My original inspiration for this post came from steven ostermiller’s blog post that no longer exists from my last check in May, 2024.

https://blog.ostermiller.org/removing-and-purging-files-from-git-history/

I was able to find it on the way back machine though.

https://web.archive.org/web/20240222195617/https://blog.ostermiller.org/removing-and-purging-files-from-git-history/

git log --all --pretty=format: --name-only --diff-filter=D | sed -r 's|[^/]+$||g' | sort -u
git filter-branch --tag-name-filter cat --index-filter 'git rm -r --cached --ignore-unmatch FILE_LIST' --prune-empty -f -- --all
rm -rf .git/refs/original/
git reflog expire --expire=now --all
git gc --aggressive --prune=now
git push origin --force --all
git push origin --force --tags
cd MY_LOCAL_GIT_REPO
git fetch origin
git rebase
git reflog expire --expire=now --all
git gc --aggressive --prune=now