如何永久删除git仓库中敏感文件的提交记录。
官方资料:
https://help.github.com/articles/remove-sensitive-data/
http://git-scm.com/book/zh/v2/Git-%E5%B7%A5%E5%85%B7-%E9%87%8D%E5%86%99%E5%8E%86%E5%8F%B2
http://stackoverflow.com/questions/2004024/how-to-permanently-delete-a-file-stored-in-git
下载git2.2.1并将git添加到环境变量中
># wget https://github.com/git/git/archive/v2.2.1.tar.gz
># tar zxvf v2.2.1.tar.gz
># cd git-2.2.1
># make configure
># ./configure --prefix=/usr/local/git --with-iconv=/usr/local/libiconv
># make all doc
># make install install-doc install-html
># echo "export PATH=$PATH:/usr/local/git/bin" >> /etc/bashrc
># source /etc/bashrc
查看版本号
># git --version
>git version 2.2.1
步骤整理:
假定需要删除的文件为:src/main/resources/passowrd.txtx
git filter-branch --index-filter 'git rm -r --cached --ignore-unmatch src/main/resources/passowrd.txtx' HEAD
git reflog expire --expire=now --all
git gc --prune=now
git gc --aggressive --prune=now
git push --all --force
命令执行成功后,查看远程资源库的提交记录(包括需要删除文件的提交记录),查看这个更新内容这个文件已经被删除。
本文提供了一步一步的操作指南,详细解释了如何使用Git命令永久删除仓库中包含敏感文件的提交记录,确保数据安全。
2135

被折叠的 条评论
为什么被折叠?



