0

IS there a way to retrieve back my laravel app files after I typed

git rm -r *

I just want to delete the files that I just deleted in the directory with

git rm data.txt

But all of them. Then I mistakenly typed

git rm -r *

Now most of my app directories are all gone.

these are now what's left

App FOlder left

user2340612
  • 10,053
  • 4
  • 41
  • 66
Inertia
  • 57
  • 7

2 Answers2

1

As noted in the comment by Inertia, git reset --hard would return your index and working tree to the last committed state. You could also do a git reset HEAD to get your index back and then git checkout [files or folders] if you want to keep any other uncommitted changes.

Morten
  • 634
  • 5
  • 13
0

In order to restore just one specific deleted file, make sure to add -- before the file name:

 git reset -- path/to/deleted/file && git checkout -- path/to/deleted/file

The -- is needed as a qualifier for a file, as git would not know whether it's a file or a branch.

k0pernikus
  • 60,309
  • 67
  • 216
  • 347