I forgot to add certain files to my .gitignore when I began my project and consequently committed files I shouldn't have. I ignored the files afterwards as described here. The damage has already happened though since the files still exist in the history of my repository and now my repository is 10gb in size!
I have not pushed the files for the aforementioned reason, so rewriting history should be okay. In short, what I need to do is to rewrite history so that afterwards none of the files in the current
To reset the commit histories as original, you can use
git reset --hard origin/branchname.
To ignore files and remove them from history, you can follow below two aspects:
.gitignorefile (if you don’t have) by
.gitignore. The wildcard is allowed. Then commit the changes.
Ignore the files from committed history:
git rm filename –r --cached
git filter-branch --index-filter 'git rm --ignore-unmatch -r --cached filename' --prune-empty -f -- --all
To tidy your local repository (you can also skip this step):
rm -Rf .git/refs/original rm -Rf .git/logs/ git gc git prune --expire now
To push the rewrite history to remote:
git push -f --all