POOJA GUPTA
POOJA GUPTA

Reputation: 2355

How to recover files in git deleted via command git clean -xdf without any commits

I mistakenly have deleted all the files in the local repository via command git clean -xdf which did not commit for once since the creation. One of my codes was not working. It prompted me to use

git clean -xdf.

It removed all the files and my data. Is there any way to recover these?

Upvotes: 0

Views: 5908

Answers (1)

Fareed Khan
Fareed Khan

Reputation: 2933

It is sad but the answer is no you cannot recover it using git.

Git does not know about them unless you committed them once.

If you are lucky and use git add before deleting the files accidently then you can run this command to recover

git fsck | awk '{print $3}' | xargs git show | tee searchresults.log

You can also use recovery software to recover your deleted files

Software such as photorec or Recuva, you can find plenty of them.

Upvotes: 4

Related Questions