git filter-branch --index-filter "git rm -rf --cached --ignore-unmatch .env" HEAD # If it is available on remote repo git push --force