how do i recover deleted files from the command git rm -r * with files that were commited but wasnt pushed

108 Views Asked by At

i accidentally removed file from his repository in github (and i had a lot of changes in some of my files, because i didn't push them yet), and after i remote back to the same repository in github -iv'e added the files again, i made a commit to the files, and when i tried to push i got this error - "fatal: You are not currently on a branch." I tried to "fix" the situation, and made the command - "git rm -r *" and ALL my the content of the file got deleted from my computer. I really dont know what to do now and how do i recover those files back (just a reminder - the current branch on github is not updated to my last commit - because no push was made)

1

There are 1 best solutions below

6
eftshift0 On

You can get them back with git checkout -- filepath

git checkout -- file1 file2

And so on. They will be checked out as they were on HEAD.