Here we will be explaining how to recover deleted files in Git


Git Version

Below mentioned commands were executed in git version


Assume that you had deleted two files Article.html and and you haven’t committed yet, then executing git status would display the deleted files in red.

> git status
On branch master
Your branch is up to date with 'origin/master'.

Changes not staged for commit:
(use "git add/rm ..." to update what will be committed)
(use "git checkout -- ..." to discard changes in working directory)

deleted: Article.html

no changes added to commit (use "git add" and/or "git commit -a")


Now executing the below command will display all the unstaged changes after RESET.

> git reset HEAD Article.html
Unstaged changes after reset:
D Article.html


You can now recover the deleted files using the below command:

git checkout -- Article.html



Was this answer helpful? 0 Users Found This Useful (0 Votes)