Last Updated: February 25, 2016
·
773
· ashish

Git - Getting the file back from a commit

git show HEAD~4:file.html > oldFile.html

2 Responses
Add your response

git distinguishes references from file paths via --. The following plucks the file from 4 commits back and stages it.

git checkout HEAD~4 -- file.html
over 1 year ago ·

So this should also effectively bring back a deleted file?

I use git show HEAD~4 when there is a need to see and recover some of the over-written changes.

over 1 year ago ·