Git:如何永久删除提交的文件? [英] Git: How to delete committed file permanently?

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

问题描述

我已经提交了一个不应该在git仓库中的文件。
我删除了它并提交了删除,但我仍然可以通过git历史访问该文件。



如何删除已提交的文件永久性的,以便它没有任何痕迹? $ C>滤波器分支。它将在您的存储库的每个修订版本的参数中应用该命令。

  git filter-branch --tree-filter'rm -rf your_file'HEAD 

这篇详细的文章可能对你有所帮助。 git文档也非常有帮助。

正如评论中提到的,你还需要一个 git gc 来清理你的本地提交, code> git push 来更新远程仓库。


I have committed a file that shouldn't be in a git repository. I have deleted it and committed the deletion, but I can still access the file via the git history.

How do I delete a committed file permanently, so that there is no trace of it?

解决方案

You can remove permanently a file using filter-branch. It will apply the command in argument in every revision of your repository.

git filter-branch --tree-filter 'rm -rf your_file' HEAD

This detailed post might help you. The git doc is pretty helpful too.

As mentioned in the comments, you will also need a git gc to clean your local commits and then git pushto update your remote repository.

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

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