My Profile Photo

Rich Werden

A simple site for Rich to write about code and archive some completed projects for future reference...

#TIL: Earlier Verions of git files

I had a specfic file that I wanted to see an older-than-the-last-commit version of from a specific past commit.

The pattern to do this is git show <treeish>:<filename>

Ex: Show the version of foo.html from four commits ago:
(Don’t forget that to go ‘backwards’ from the HEAD [last commit] we use the ~ and not -):

git show HEAD~4:foo.html