Git:如何永久删除提交的文件? [英] Git: How to delete committed file permanently?
问题描述
我已经提交了一个不应该在git仓库中的文件。
我删除了它并提交了删除,但我仍然可以通过git历史访问该文件。
如何删除已提交的文件永久性的,以便它没有任何痕迹? $ C>滤波器分支。它将在您的存储库的每个修订版本的参数中应用该命令。
git filter-branch --tree-filter'rm -rf your_file'HEAD
正如评论中提到的,你还需要一个 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 push
to update your remote repository.
这篇关于Git:如何永久删除提交的文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!