Specify the restore location. If neither option is specified, by default the working tree is restored. Specifying --staged will only restore the index.Specifying both restores both.
git reset HEAD --hard
command will merge pull request from the originator branch ,so you will find the deleted file
I had the same problem however none of the above solutions worked for me. What I ended up doing was:
- create an empty file with the same name
- compare this file with its local history
- copy history across to empty file.
One solution without any risks is to go to your repository page (on github etc.) and download the deleted file by hand.
I had the same problem and none of the answers here I tried worked for me either. I am using Intellij and I had checked out a new branch git checkout -b minimalExample
to create a "minimal example" on the new branch of some issue by deleting a bunch of files and modifying a bunch of others in the project. Unfortunately, even though I didn't commit any of the changes on the new "minimal example" branch, when I checked out my "original" branch again all of the changes and deletions from the "minimal example" branch had happened in the "original" branch too (or so it appeared). According to git status
the deleted files were just gone from both branches.
Fortunately, even though Intellij had warned me "deleting these files may not be fully recoverable", I was able to restore them (on the minimal example branch from which they had actually been deleted) by right-clicking on the project and selecting Local History > Show History (and then Restore on the most recent history item I wanted). After Intellij restored the files in the "minimal example" branch, I pushed the branch to origin. Then I switched back to my "original" local branch and ran git pull origin minimalExample
to get them back in the "original" branch too.