如何删除不小心推送的东西

发布于 2025-01-04 20:13:16 字数 180 浏览 0 评论 0原文

我想在我的网站上进行源代码控制。有很多文件,所以我只是去了 git add -a

不幸的是,我不小心提交并推送了一个名为 credential.txt 的文件,其中包含我的 ftp 和 db 详细信息。我尝试删除该文件,提交然后推送,但当我浏览 github 上的历史记录时,它仍然显示该文件。

有办法摆脱这个吗?

I wanted to do source control on my website. There were a lot of files so I just went git add -a

Unfortunately, I accidentally committed and pushed a file called credentials.txt that had my ftp and db details. I've tried deleting the file, committing then pushing but it still shows the file when I browse my repo on github in the history.

Is there anyway to get rid of this?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

挽清梦 2025-01-11 20:13:16

Github 有一个关于这个主题的很好的指南。它解释了如何将其从存储库中取出,以及如何处理可能已经掌握在公众手中的数据。

Github has a nice guide on this exact topic. It explains how to get it out of the repository, as well as how to deal with the data that may already be in public hands.

维持三分热 2025-01-11 20:13:16

您必须使用 git filter-branch 重写历史记录。 Andy 发布了github 上执行此操作的指南的链接。

不管怎样,删除该文件并不能消除损害——任何同时拉取你的存储库的人都拥有它,并且至少它在 github 的基础设施中。所以,别打扰。

不要试图隐藏发生的事情,而是进行损害控制并更改密码。不要试图保守一个已经泄露的秘密——引用本杰明·富兰克林的话,“三个人保守秘密的唯一方法就是其中两个人死了”。

如果它在互联网上存在哪怕一小会儿,就可以肯定地认为它已经被十几个人或更多的人保存了。如果你不从这个角度工作,它可能会反过来咬你一口。

You'll have to rewrite history using git filter-branch. Andy has posted a link to a guide on github for doing this.

Regardless of that, removing the file won't undo the damage - anyone who pulled your repo in the meantime has it, and at the very least it's in github's infrastructure. So, don't bother.

Instead of trying to hide what happened, do damage control and change your passwords. Don't try to contain a secret that's already out - to quote Benjamin Franklin, "the only way three people can keep a secret is if two of them are dead".

If it's on the Internet even for a moment, it's safe to assume it's been saved by a dozen or more people. If you don't work from that perspective it will probably come back to bite you.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文