Git:如何删除现在在gitignore中但之前已添加到仓库中的文件 [英] Git: How to remove files that are now in gitignore but were added to repo before
问题描述
我在存储库和.gitignore中都有几个文件.
I have a couple of files that are in the repo and also in .gitignore.
我希望在执行git pull origin master
我尝试了多种解决方案,但都没有接缝能用,在每一种解决方案中,我最终都会在执行拉动操作时从服务器上删除文件.
I have tried multiple solutions but none seam to work, in each one I end up deleting the files from the server when I do a pull.
参考:
如何使Git忘记"关于已被跟踪但现在位于.gitignore中的文件?
推荐答案
您首先需要git filter-branch
,然后要求所有人重新整理根据您的旧历史创建的分支.
You need git filter-branch
first, then ask everybody to rebase branches created off of your old history.
请参阅: https://help.github.com/articles/remove-敏感数据/
这很复杂,可能会导致问题,因此下次请小心,以免到达那里.
This is complex, and might cause issue, so next time be careful so not to get there.
如果由于某种原因您无法执行此操作,则需要等到机器发明出来的时间:)
If you can't do that due to some reason, then need to wait until time machine invented :)
这篇关于Git:如何删除现在在gitignore中但之前已添加到仓库中的文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!