This repository had a large subdirectory of large files that months ago I removed from the commit and that I now want to remove from the repo forever. The massive subdirectory is no longer in the download but the objects directory is enormous.
The checkouts/clones take a long time and I believe this is because of the large .git/objects directory.
repo <files to keep> <massive subdirectory>
I want to remove the massive subdirectory.
The link above has a long discussion of a procedure that I've put to this script :
#!/bin/bash if [ -z "$1" ]; then echo "missing argument: subdirectory to remove" exit fi git filter-branch --tree-filter 'rm -rf $1' --prune-empty HEAD git for-each-ref --format="%(refname)" refs/original/ | xargs -n 1 git update-ref -d echo $1/ >> .gitignore git add .gitignore git commit -m 'Removing $1 from git history' git gc git push origin master --force
I have run this without obvious errors and then cloned the repo to find that the .git/objects directory is not reduced in size.
Is the script missing something? Am I missing something? Has a recent version of git introduced a more direct feature for this requirement?
Is there another approach?