testdisk
testdisk copied to clipboard
Lost all project files after git reset --hard β how to recover ?
Description
I encountered an issue where all files in my JavaScript project folder (D:\JavaScript_Repo) were deleted after running: git reset --hard
I was trying to fix some line ending warnings (LF will be replaced by CRLF), and ran git reset --hard to clear changes. But it seems to have removed all my project files (not just untracked ones).
What I Did
- Cloned repo using Git Bash/PowerShell.
- Installed
node_modules. - Got repeated warnings like: warning: LF will be replaced by CRLF the next time Git touches it
- Ran
git config --global core.autocrlf true - Then ran: git reset --hard
But after that, most of my files and folders were deleted, including node_modules, src, etc.
π What Iβve Tried
- I checked
git reflogβ but couldn't recover untracked files. - Using
PhotoRecnow, but itβs hard to recover the exact folder structure. - I want a safer or Git-based method if available.
β What I Need Help With
- Is there any way to recover the files removed by
git reset --hard? - Can GitHub/Git help in recovering untracked but deleted files?
- What are the safest practices to avoid this kind of loss in the future?
π§ Additional Info
- Windows 10
- Local repo, not published on GitHub yet
- Files were not committed before deletion
π Iβd really appreciate guidance on recovery options (Git or non-Git) β this is a serious project loss for me.
You can try
- TestDisk, Advanced, Undelete. Be careful to store the recovered files on another partition than the source partition.
- "git fsck --lost-found" and check files in .git/lost-found/
- "git reflog show" followed by a "git reset XXXX" where XXX is the commit you want