In the past, I accidentally made a large number of Java artifacts (.war, .jar and .class) in my GitHub repo. This led to a huge bloat of up to 100 MB. I did not notice that many commits and branches merge later.
Fortunately, there is a lot of information about this, so after endlessly trawling through the documentation of StackOverflow, GitHub and Git (thanks everyone!) I finally managed to add the following script:
#!/bin/bash echo "Removing history for *.war, *.jar, *.class files" echo "Starting size" git count-objects -v echo "Removing history for *.war, *.jar, *.class files" git filter-branch --force --index-filter 'git rm --cached --ignore-unmatch *.war' --prune-empty --tag-name-filter cat -- --all git filter-branch --force --index-filter 'git rm --cached --ignore-unmatch *.jar' --prune-empty --tag-name-filter cat -- --all git filter-branch --force --index-filter 'git rm --cached --ignore-unmatch *.class' --prune-empty --tag-name-filter cat -- --all echo "Purging refs and garbage collection"
This worked perfectly in place, my 100Mb repo dropped to about 2 MB. Then i used
git push --all origin --force
to overwrite all branches in the GitHub repository with my local changes. Everything went well. To check everything, I deleted the local repo and cloned from GitHub. It should have been 2Mb, but again it was 100Mb.
So, after all this rambling, where did I go wrong? How to get GitHub to use my local repo with its cleared history?
Editing for more information.
The GitHub repository cannot be deleted, as it contains a lot of additional information (questions, wikis, watches, etc.). Running this script for an empty repo scratch works fine - the cloned repo is 2 MB.
The problem remains why it does not work with the main repo.