第一步:切換到git本地庫的最上一級git
第二步:遞歸重寫git歷史服務器
# git filter-branch --tree-filter 'rm -f admin/test.sh ' --tag-name-filter cat -- --ide
Rewrite a24d4b153f783cca0554feed3188426ae79ea27d (410/410)遞歸
Ref 'refs/heads/develop' was rewrittenrem
Ref 'refs/heads/master' was rewrittenit
Ref 'refs/remotes/origin/develop' was rewrittenio
Ref 'refs/remotes/origin/master' was rewrittenast
第三步:強制push到服務器class
# git push origin --tags --forcethread
Warning: Permanently added 'a.b.c.d' (ECDSA) to the list of known hosts.
Everything up-to-date
[root@product-bastion init]# git push origin --all --force
Warning: Permanently added 'a.b.c.d' (ECDSA) to the list of known hosts.
Counting objects: 9, done.
Delta compression using up to 2 threads.
Compressing objects: 100% (7/7), done.
Writing objects: 100% (7/7), 1.73 MiB | 0 bytes/s, done.
Total 7 (delta 2), reused 0 (delta 0)
To git:init
+ a24d4b1...ae92382 develop -> develop (forced update)
+ a24d4b1...ae92382 master -> master (forced update)
第四步:檢查確認私密文件已經被清理出git庫。