Undo a git clean

5.1k Views Asked by At

I have been having problems with pulling from git to my server for a few days with it saying one file was untracked, after reading github i ran git clean -d -f and its basically removed a whole ton of stuff, is there a way to undo this? im really stuck at the moment i had a couple of people from another country contribute to the project and since then everything's just got into a whole mess.

enter image description here

2

There are 2 best solutions below

1
Pedro Ramos On

Some IDEs like IntelliJ and Eclipse allow you to recover files from a local history. If you happen to be using one of those IDEs, you could try out this feature.

0
Ente On

No. Git can't undo a git clean.

Those files were deleted and never tracked by git. Git won't help you since it never knew about those files in the first place. You have to recover those files from the block device directly, or use an other mechanism.

Also I would suggest that you re-mount the device on which the repository was stored read-only now. (sudo mount -o remount,ro /path/to/mountpoint). With every write operation to that device, your chances of a successful recovery become slimmer and slimmer.