- You are working on a featur branch and delete an existing file
- You continue working on your feature branch
- You realise you should not have deleted the file and want to reinstate it
$ git log --diff-filter=D --summary
This will list all the commits which have deletions. Find the one containing the file you want to reinstate and copy its commit id. Use it, and the file name (with full path) in the following command:
$ git checkout <<commitId>>~1 <<file_to_reinstate>>
The ~1 is important to append to the commitId. It means get the first grandparent of the commit.