Git - 删除并排除配置文件
两周前,我提交了包含密码的应用程序的配置,但它不是很有用。 如何从提交历史记录中删除该文件并确保它不会被重新提交?
我想从所有提交树中删除该文件,因为它包含我的密码。
2 weeks ago, I commited config of my application which had my password, it's not very useful.
How can I remove the file from the commit history and make sure it doesn't get re-commited?
I want to remove the file from all commits tree because it contains my passwords.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
您可以
另一种极端的方法(特别危险,特别是如果您已经将存储库推送到远程存储库)是从所述存储库的历史记录中完全删除该文件:(
小心使用,并首先进行备份)
问题< a href="https://stackoverflow.com/questions/872565/how-do-i-remove-sensitive-files-from-gits-history">如何从 git 历史记录中删除敏感文件 有更多内容关于这个敏感话题。
此过程存在双重问题:
要解决此问题,他们必须删除现有存储库并重新克隆它,或者按照
git-rebase
手册页。在这两种情况下,您的机密信息都不会被“悄悄”替换或删除......
You can
The other extreme approach (dangerous especially if you have already pushed your repo to a remote one) would be to entirely remove that file from the history of said repo:
(to use with care, and with a backup first)
The question How do I remove sensitive files from git’s history has more on that sensitive topic.
The problems with this process are twofold:
To fix this, they'll have to either delete their existing repository and re-clone it, or follow the instructions under "
RECOVERING FROM UPSTREAM REBASE
" in thegit-rebase
manpage.In both case, your confidential information will not be "quietly" replaced or erased...
将文件名添加到 .gitignore 文件中。
链接
Add the file name to a .gitignore file.
Link
使用忽略: http://github.com/guides/ignore-for-git
Use ignore: http://github.com/guides/ignore-for-git