How to remove large file permanently for the whole team

Someone in my team pushed a large file to the git server and everyone in the team now has a clone of the project with the large file.

I followed the guide in http://help.github.com/removing-sensitive-data/ and it works in my local source tree as well as on the remote server. But once another person fetches the new data from the remote server, he will easily reintroduce the large file by pushing new commits to the server.

Normally a team member will do the following to share his commit with others:

git fetch origin
git rebase origin/master
git push origin

In the step of 'rebase', the old large file is reintroduced in his local commits. Of course a direct way is to demand everyone in the team to re-clone the project after I remove the large file, but not everyone would be happy to do so. I'm finding any way other than re-cloning the whole project for everyone.

Any suggestions? Thanks.


take a look at filter-tree. You need to edit the commit that introduced the file. Once that is done, everyone can fetch. This will make non-fast-forward remote branches in their repos - each commit after removing the offending file will be different now. When they rebase their current changes on top of the new remote branches, it should not push the large object anymore.

An alternate is to do a git rebase --preserve-merges -i where you edit the offending commit.


如果删除大文件的执行时间合理,您可以编写一个脚本来删除文件,指示所有人在rebase之后在本地运行脚本,并使用挂钩检查是否不重新引入该脚本。


The progit book has an elaborate example using git filter-branch (not filter-tree as the other post mentions). The chapter is here

' Removing Objects ' http://progit.org/book/ch9-7.html

链接地址: http://www.djcxy.com/p/5464.html

上一篇: CSS:隐藏光标而没有任何外部文件

下一篇: 如何永久删除整个团队的大文件