15 July 2013

How to Undo delete file in git ?

Did you delete a  file by accident ?
(due misclick , you went wild while you drunk and decide to delete file or as me you delete file without wear a glasses first.).

What to do ? Well, In normal cases,below steps are enough ..

1) Go to right project directory
2) type:
  • git reset HEAD *DeletedFile.name
3) type:
  • git checkout *DeletedFile.name
4) type:
  • git status to ensure that everything went smoothly

If you got into deep trouble,then search in stackoverflow as they have many solutions for various bizarre cases .

And advice to myself:
Do not delete files without wearing glasses first.