fhalwa
Last Updated: February 25, 2016
·
609
· ashish

Git - Getting the file back from a commit

git

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

2 Responses
Add your response

6541

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 ·
6542

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 ·
Filed Under