Git 删除历史中的大文件或者敏感文件

git verify-pack -v .git/objects/pack/*.idx | sort -k 3 -n | tail -3
git rev-list --objects --all | grep 343940a
git log --pretty=oneline --branches -- _src/归档.zip

git filter-branch --force --index-filter 'git rm --cached --ignore-unmatch _src/归档.zip' --prune-empty --tag-name-filter cat -- --all

rm -Rf .git/refs/original
rm -Rf .git/logs/ 
git reflog --all  
git prune  
git gc  
du -hs

git count-objects -v

 

删除敏感文件:

# 假设要删除的文件是password.txt,运行如下命令:
git filter-branch --index-filter 'git rm -r --cached --ignore-unmatch src/main/resources/passowrd.txt' HEAD

git filter-branch --force --index-filter 'git rm -r --cached --ignore-unmatch src/main/resources/passowrd.txt' HEAD

# 如果commit已经同步到了github,那么再运行如下命令永久删除远端上的文件。

git push --all --force

 

 

参考:

https://help.github.com/articles/removing-sensitive-data-from-a-repository/

https://blog.csdn.net/meteor1113/article/details/4407209

https://help.github.com/articles/removing-sensitive-data-from-a-repository/

https://blog.csdn.net/zcf1002797280/article/details/50723783

 

修改时间 2019-01-14

声明:本站所有文章和图片,如无特殊说明,均为原创发布。商业转载请联系作者获得授权,非商业转载请注明出处。
真诚赞赏,手留余香
赞赏
随机推荐
MySQL DATETIME 时间查询和转换
Linux 中 top 命令的 Load Average 含义
WordPress 实现自定义 Ajax 请求
Flame 插件
视频剪辑软件 Shotcut 笔记
Node.js 的 URL 的模块
WordPress 添加 Favicon 图标的方法
如何使用命令修改 MySQL 数据库名称