Skip to content

Instantly share code, notes, and snippets.

@darong-khalibre
Last active August 29, 2015 14:02
Show Gist options
  • Save darong-khalibre/bdd282fc4b401a0b5354 to your computer and use it in GitHub Desktop.
Save darong-khalibre/bdd282fc4b401a0b5354 to your computer and use it in GitHub Desktop.
Restore delete files in git
# show all changes of a file, work even if the file is deleted
git log -- docroot/user_bars/logo.png
# limit the output of Git log to the last commit, i.e. the commit which delete the file
# -1 to see only the last commit
# use 2 to see the last 2 commits etc
git -1 log -- docroot/user_bars/logo.png
# view the content of the file in a specific commit; note that the file is not deleted in that commit
git show f5ac172e docroot/user_bars/logo.png
# restore file from a specific commit
git checkout f5ac172e docroot/user_bars/logo.png
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment