Skip to content

Lost all project files after git reset --hard — how to recover ? #172

Open
@ashishmi8113

Description

@ashishmi8113

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

  1. Cloned repo using Git Bash/PowerShell.
  2. Installed node_modules.
  3. Got repeated warnings like: warning: LF will be replaced by CRLF the next time Git touches it
  4. Ran git config --global core.autocrlf true
  5. 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 PhotoRec now, 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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions