Skip to content

Instantly share code, notes, and snippets.

View RoelVdP's full-sized avatar
🏠
Working from home

Roel Van de Paar RoelVdP

🏠
Working from home
View GitHub Profile
@RoelVdP
RoelVdP / new_gist_file
Created March 22, 2018 10:35 — forked from marioflores/new_gist_file
Restore files with Git
If the deletion has not been committed, the command below will restore the deleted file in the working tree.
$ git checkout -- <file>
You can get a list of all the deleted files in the working tree using the command below.
$ git ls-files --deleted
If the deletion has been committed, find the commit where it happened, then recover the file from this commit.
$ git rev-list -n 1 HEAD -- <file>
$ git checkout <commit>^ -- <file>