Published on

How to delete the entire git history from a file

Inside the terminal, type:

git filter-branch --tree-filter 'rm -f <yourfile>' HEAD

git push origin --force --all

Then, depending on your operating system...

For Linux: rm -rf .git/refs/original/

For Windows: Remove-Item -Path .git\refs\original -Recurse -Force

And finally..

git reflog expire --expire=now --all git gc --prune=now --aggressive