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

Git - Getting the file back from a commit

git

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

Say Thanks
Respond

2 Responses
Add your response

6541
15927fc52919e9223adc7ed99e125d4d

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