Recover git files created and deleted in a single commit

58 Views Asked by At

I've made a huge beginner mistakes while using git. I created several python files, then deleted them accidently, and then commited. So now the files aren't there anymore but they're unknown to git because they didn't exist in the last commit.

Is there a way to retrieve them ?

Thanks a lot !

1

There are 1 best solutions below

1
On

In short: No, you can not retrieve the files.

As you describe it, there is no "git" way to retrieve them. Only when files have been added and commited using git add and git commit, git knows about the files.
Git also keeps track of a state of a file if you stashed it, but I don't think you did that.

Git is not "running in the background" and tracking everything that happens in the directory. You need to invoke specific commands to interact with git.