从未push的最近一次commit中删除
使用git rm -cached
和git commimt amend -CHEAD
命令
git rm --cached file # 从缓存中删除,在disk中保留
git commimt amend -CHEAD # 修补上次commit
从较早的commit中删除
使用git filter-branch
操作或者BFG Repo-Cleaner工具。
参考博客https://www.cnblogs.com/imzhizi/p/delete-files-thoroughly-using-bfg.html
https://help.github.com/en/github/managing-large-files/removing-files-from-a-repositorys-history
https://help.github.com/en/github/authenticating-to-github/removing-sensitive-data-from-a-repository