1.修改author和committer
git filter-branch --commit-filter ' export GIT_AUTHOR_EMAIL=me@example.com; export GIT_AUTHOR_NAME=me; export GIT_COMMITTER_EMAIL=me@example.com; export GIT_COMMITTER_NAME=me; git commit-tree "$@" '
2.刪除誤提交的檔案
a.用git filter-branch對所有分支上的commit執行命令操作,忽略對該檔案的追蹤,
將其從git倉庫中移除,並重寫每一條記錄
//從指定的commit中刪除誤操作檔案的記錄 git filter-branch --tree-filter 'git rm -f --ignore-unmatch {{檔名}}' [commit1..commit2] //從當前分支的前30次提交開始遍歷,刪除誤操作檔案的引用 git filter-branch --tree-filter 'git rm -f {{檔名}}' HEAD~30..HEAD
b.強制推送到遠端
git push origin master --force
出處:https://walterlv.oschina.io/git/2017/09/19/delete-file-using-filter-branch.html
出處:http://www.jianshu.com/p/099e644b60fb