1. 程式人生 > >git filter-branch應用

git filter-branch應用

-i mit for 操作文件 執行命令 http .html span 記錄

1.修改author和committer

git filter-branch --commit-filter export GIT_AUTHOR_EMAIL=[email protected];
export GIT_AUTHOR_NAME=me;
export GIT_COMMITTER_EMAIL=[email protected];
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

git filter-branch應用