I accidentally deleted files from my repo with git clean. I was trying to explore git from vs code and deleted my all files with git clean and those files were not staged or committed. Is it possible to restore these files?
Asked
Active
Viewed 234 times
0
-
3`git clean` deletes files that aren't version controlled. You're out of luck if you don't have a backup somewhere. – John Kugelman Feb 02 '23 at 05:21
-
3Unfortunately, if the files were deleted with git clean, they are not recoverable as git clean permanently removes untracked files from the file system. The only way to restore these files is if you have a backup of the deleted files or if you have committed the changes before running git clean. – Gowtham Feb 02 '23 at 05:21
-
I want those files back i don't know what should i do :( – Lambda Feb 02 '23 at 06:02
-
Sorry to say, **it happens. `git clean` is a sharp knife. Its only protection is that you must use `-f` to say "yeah, I mean it". – j6t Feb 02 '23 at 06:22
-
1As others said, if they have not been staged, from git point of view they are lost. But you could try a file recovery tool like https://www.cgsecurity.org/wiki/PhotoRec And I don't know if vscode file history feature could help for new files: https://stackoverflow.com/a/46830780/717372 – Philippe Feb 02 '23 at 07:36
-
1Well, thanks for the replies. I tried with the recovery tool and got the files only but not all. At least reduce my work of rewriting all the files. – Lambda Feb 02 '23 at 09:40