简体   繁体   English

恢复在一次提交中创建和删除的 git 文件

[英]Recover git files created and deleted in a single commit

I've made a huge beginner mistakes while using git.我在使用 git 时犯了一个巨大的初学者错误。 I created several python files, then deleted them accidently, and then commited.我创建了几个python文件,然后不小心删除了它们,然后提交。 So now the files aren't there anymore but they're unknown to git because they didn't exist in the last commit.所以现在这些文件已经不存在了,但是 git 不知道它们,因为它们在上次提交中不存在。

Is there a way to retrieve them ?有没有办法找回它们?

Thanks a lot !非常感谢 !

In short: No, you can not retrieve the files.简而言之:不,您无法检索文件。

As you describe it, there is no "git" way to retrieve them.正如您所描述的,没有“git”方式来检索它们。 Only when files have been added and commited using git add and git commit , git knows about the files.只有当使用git addgit commit git addgit commit文件时,git 才知道这些文件。
Git also keeps track of a state of a file if you stashed it, but I don't think you did that.如果您将文件藏起来,Git 还会跟踪文件的状态,但我认为您没有这样做。

Git is not "running in the background" and tracking everything that happens in the directory. Git 不是“在后台运行”并跟踪目录中发生的一切。 You need to invoke specific commands to interact with git.你需要调用特定的命令来与 git 交互。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM