I accidentally run the command "git clean -df", so I lost many directories and files, I want to recover them, I don't have backup in time machine. I tried some software to recover, but they don't work.
2 Answers
If you are working with an online repository and you keep it up-to-date you can download all the file from the online repository using the following commands:
git pull # in the case the remote is set
git clone <address_of_repository> # in the case the remote is not set
Using these commands you'll be able to restore your deleted files, obviously only if the online repository is up to date.
I also ran into same issue unknowingly ran git clean -df and git clean -xf, but fortunately I am using php storm and it saves local history by which I am able to recover the deleted files.
If you are also using any IDE then check if it has local history.
-
No. The answer is to use a proper backup regime. This covers all files as asked in the question. An IDE might protect some files but that is not its purpose, definitely not non source code files and in the OPs case the backups the IDE keeps might have been deleted as well.– mmmmmmMay 7, 2021 at 14:47
git clone
orgit pull
.