意外恢复已删除的文件

发布于 2024-11-30 02:32:37 字数 373 浏览 1 评论 0原文

我刚刚引发了一个问题,但我无法找到解决方案。我一直在开发一个已有一年历史的 Ruby On Rails 应用程序,该应用程序存储在 Git 存储库中。

我删除了许多文件,多次提交前,但从未使用 git rm filename 从存储库中删除文件。

最近我做了一个 git stash save --keep-index 、 git stash drop 来丢弃一些错误的代码并返回到上次提交。但是,当我这样做时,未从存储库中删除的已删除文件已被恢复。

现在我的项目由于存在文件而崩溃,而这不应该。有什么方法可以重新删除文件,或获取已恢复的已删除文件的列表?

我尝试用谷歌搜索这个问题,但是谷歌返回了“git Restore意外删除的文件”的结果,这与我正在寻找的相反。

I just caused a problem that I'm having trouble finding a solution for. I have been working on a year old Ruby On Rails app, which is stored in a Git repository.

I deleted many files, several commits ago, but never did a git rm filename to remove the files from the repository.

Recently I did a git stash save --keep-index, git stash drop to discard some bad code and go back to the last commit. However when I did this, the deleted files which were not removed from the repository have been restored.

Now my project is crashing because of files that exist, which should not. Is there any way I can re-delete the files, or get a list of the deleted files which were restored?

I tried googling this problem, but google helpfully returns results for "git restore accidentally deleted files" which is the opposite of what I am looking for.

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

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

发布评论

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

评论(1

表情可笑 2024-12-07 02:32:37

存储成为图中的提交节点,仅仅因为您删除了它并不意味着它就永远消失了。它最终会被垃圾收集,但只要您最近删除了它,您应该能够找到它并将其作为存储或提交添加回您的“常规”历史记录中。只需四处看看如何恢复丢失的存储或如何找到悬空/丢失的提交。像这个这个,或 这个,也许吧。

A stash becomes a commit node in the graph, and just because you dropped it doesn't mean it's gone forever. It'll be garbage collected eventually, but as long as you dropped it relatively recently, you should be able to find it and add it back into your "regular" history as either a stash or a commit. Just look around for how to recover dropped stashes or how to find dangling/lost commits. Something like this, this, or this, perhaps.

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