git 库永久删除大文件

无意中把一个装有很多大文件数据的文件夹(./my1202260986)提交了,现在.git有681MB之大
$ du .git -hd0
681MB  .git

不过还没有push出去。我用如下命令清除了错误提交的大文件:

$ git filter-branch --index-filter 'git rm -r --cache --ignore-unmatch my1202260986/*' HEAD

$ git gc --aggressive --prune=now

$ du .git -hd0
112K    .git


如果push了,还要更复杂一点。参考
https://help.github.com/articles/remove-sensitive-data



猜你喜欢

转载自cryolite.iteye.com/blog/1766097