I was trying to clear my git after adding files from the wrong directory and ran the git clean -df function. This resulted in all my user data being deleted.
I haven't done anything more in git after this, and I don't dare to turn of my PC at the moment. However, I noticed that there is a .git folder which contains about 600MB of data. Is it possible that y files are stored there and can be recovered?
I run Windows 10 and do not have any backup or restore points for the user data folder.
Any help would be greatly appreciated as I had som really important data stored. Thank youAnswer1:
There's no way to recover from this unless you had a backup or want to explore using undelete utilities. Git is not saving backups anywhere.Answer2:
Short answer and most probable there is not!!
Still some IDE's track and store locally this information see for example: <a href="https://stackoverflow.com/questions/9750049/is-it-possible-to-restore-deleted-untracked-files-in-git" rel="nofollow">Is it still possible to restore deleted untracked files in git?</a>
So depending on your IDE or text editor it still might be possible.Answer3:
If you're using Eclipse, and you're only missing code or text, don't despair, not all may be lost. Go to:
FINDSTR (Windows) or a similiar tool to search for text snippets you know to have occurred in the deleted files. Eclipse keeps a lot of local history revisions around, so if you worked on these files recently, you will probably have <strong>a lot</strong> of matches. Then you need to find most recent one of these, which can be a bit tricky.
To give an example: After doing a quick
git clean -d -fx to show this dangerous feature to a colleague, I was missing an untracked java code file, of which I knew it contained the String
XrefCollector. I was able to find the last local history revision by doing this:
find . -printf "%T@ %p\n" | sort -n | cut -d" " -f2 | xargs grep -l XrefCollector | tail -n1
find prepends the date (epoch) to the files,
sort sorts (numerically),
cut removes the date again, and
xargs passes the filenames on to
grep, which searches for the desired string. Finally,
tail only shows the last line of output.