I want to copy files from specified commit with GitPython. Now I come here so far:
import git
git = git.Git(REPO_PATH)
git.checkout(COMMIT_HEX_SHA)
fo = open(REPO_PATH + "/foo.txt", "r")
str = fo.read(10);
fo.close()
It works. But checkout
changes HEAD
and changes files. Is it possible to copy files or read files from specified commit without checkout
?
git.Repo().commit(COMMIT_HEX_SHA).tree['subdir/somefile.ext'].data_stream
. – Penetrate