Git - Getting the file back from a commit
git show HEAD~4:file.html > oldFile.html
Written by Ashish Kumar Singh
Related protips
2 Responses
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
·
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#Git
Authors
khasinski
591.1K
dmichaelavila
500.4K
Related Tags
#git
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#