在 GitHub上Push了带密码的文件,就算删掉文件,commit 历史还是残留的。
怎样删除commit历史呢?
方法:
使用 git filter-branch 可以替换 commit 历史,然后 --force push。
$ git filter-branch --force --index-filter 'git rm --cached --ignore-unmatch .env' --prune-empty --tag-name-filter cat -- --all
$ git push origin master --force