git checkout - How to get a copy of an older version of a file in a git repository? -
git checkout - How to get a copy of an older version of a file in a git repository? -
i have version of .tex
file number of commits ago re-create of. have sha1 hash value commit has version of file want. not want replace current version of file. rather, want separate re-create of reflects state @ older version.
a lot of similar questions suggest using git checkout <sha1> -- file.tex
, keeps giving "error: pathspec 'file.tex' did not match file(s) known git."
the file interested in existed in top-level directory of repository. in sub-directory of repository trying run command older version of file.tex in subdirectory.
is possible? how can this?
you can utilize git cat-file
dump contents of file standard output , redirect desired destination:
git cat-file -p <sha1>:./file.tex > wherever.tex
the ./
necessary if in subdirectory of repository, if you're in top-level of repository may omitted. also, may not work in older versions of git, in case you'd need explicitly supply total path file relative repository's root.
git git-checkout
Comments
Post a Comment