如何删除在git中错误提交的大文件 [英] How do I remove a big file wrongly committed in git

查看:95
本文介绍了如何删除在git中错误提交的大文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


可能存在重复:


我做了一件愚蠢的事情。想象一下,我提交了一个100MB的文件。比我看到这个并删除这个文件并再次提交。这是删除文件的正常过程。



但现在副作用是我的历史很沉重,因为它保存了这个大文件(我相信这就是它的重要原因)。我只使用本地git,所以我不会在任何服务器进行同步。



我怎样才能明确地删除这个文件并节省磁盘空间?

$ b $你可以使用git filter-branch 命令来完成这项工作,如下所示:

$ b $

  git filter-branch --tree-filter'rm -rf path / to / your / file'HEAD 

您可以在这里找到更多文档 http://dalibornasevic.com/posts/2-permanently-remove-files-and-folders-from-a-git-repository


Possible Duplicate:
How to purge a huge file from commits history in Git?

I did a stupid thing. Imagine that I committed a 100MB file. Than I see this and delete this file and commit again. This is normal procedure to delete a file.

But now the side effect is that my history is heavy because it's saved this large file (I believe this is the why it is heavy). I am only using local git, so I do not synchronize in any server.

How can I definitively remove this file and save disk space?

解决方案

You can do it using the git filter-branch command, like this :

git filter-branch --tree-filter 'rm -rf path/to/your/file' HEAD

You can find more documentation here http://dalibornasevic.com/posts/2-permanently-remove-files-and-folders-from-a-git-repository

这篇关于如何删除在git中错误提交的大文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆