Is it still possible to restore deleted untracked files in git?

let's say yesterday I did some changes on my master branch, and I forgot to add, commit them. and in the morning i did

git reset --hard

is it possible to restore deleted files in this situation ?


Solution 1:

Some better IDEs keep track of your files as a local history. If you removed files externally (say, git reset) you should be able to click in your IDE on parent directory and choose "Compare with local history".

I used this feature successfully in PHPStorm IDE when my untracked files got wiped out by some utility...

Solution 2:

git reset --hard is a very dangerous command, so be careful when you use it next time :)

If you do not have any commit for those files, it seems you have no chance restore them.

Otherwise, reflog command can help you.

Solution 3:

In Intellij how to recover the untracked revert changes

Step 1: Select the Folder , Right click on it

Setp 2: Go to Local History, and then go to Show history

enter image description here

Step 3: Select the untracked files that your revert accidentally. then select those file in right side panel and revert the changes, you will get the files in reverted format.

enter image description here