Skip to content

Instantly share code, notes, and snippets.

@thiagosf
Created June 17, 2020 14:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save thiagosf/cb1042dff7891c93635ae23cf966ae51 to your computer and use it in GitHub Desktop.
Save thiagosf/cb1042dff7891c93635ae23cf966ae51 to your computer and use it in GitHub Desktop.
Restore deleted file in git

List commits with file is inside

git log --oneline --follow -- path/to/file

The result looks like:

8266b41 Removing file
fb4d75c Another commit

Copy, for example 8266b41, and restore file like that:

git checkout 8266b41^ -- path/to/file

🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment