第一步:切换到git本地库的最上一级

第二步:递归重写git历史

# git filter-branch --tree-filter 'rm -f admin/test.sh ' --tag-name-filter cat -- --

Rewrite a24d4b153f783cca0554feed3188426ae79ea27d (410/410)

Ref 'refs/heads/develop' was rewritten

Ref 'refs/heads/master' was rewritten

Ref 'refs/remotes/origin/develop' was rewritten

Ref 'refs/remotes/origin/master' was rewritten

第三步:强制push到服务器

# git push origin --tags --force

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库。