问题描述
前一段时间,我添加了必须是私有的信息(文件).从项目中删除不是问题,但是我还需要从git
历史记录中删除它.
Some time ago I added info(files) that must be private. Removing from the project is not problem, but I also need to remove it from git
history.
我使用Git和Github(私人帐户).
I use Git and Github (private account).
注意:在此线程上,类似的内容如图所示,但是这里是一个旧文件,该文件已添加到功能分支,该分支合并到开发分支,最后合并到母版,因此,进行了很多更改.因此不一样,需要更改历史记录并隐藏该文件以保护隐私.
Note: On this thread something similar is show, but here is an old file that was added to a feature branch, that branch merged to a development branch and finally merged to master, since this, a lot of changes was done. So it's not the same and what is needed is to change the history, and hide that files for privacy.
推荐答案
我找到了这个答案,它很有帮助:
I have found this answer and it helped:
git filter-branch --index-filter "git rm -rf --cached --ignore-unmatch path_to_file" HEAD
在这里找到它 https://myopswork.com /how-move-move-files-from-git-repository-history-47ed3e0c4c35
这篇关于如何从Git历史记录中删除文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!