How to get a copy of an older version of a file in a git repository?

You can use git cat-file to dump the contents of the file to the standard output and redirect that into your desired destination:

git cat-file -p <sha1>:./file.tex > wherever.tex

The ./ is necessary if you are in a subdirectory of the repository, if you’re in the top-level of the repository it may be omitted. Also, that may not work in older versions of git, in which case you’d need to explicitly supply the full path to the file relative to the repository’s root.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)