I\'m using GitPython with a bare repository and I\'m trying to get specific git object by its SHA. If I used git directly, I would just do this
git ls-tree s
Try this:
def read_file_from_branch(self, repo, branch, path, charset='ascii'):
'''
return the contents of a file in a branch, without checking out the
branch
'''
if branch in repo.heads:
blob = (repo.heads[branch].commit.tree / path)
if blob:
data = blob.data_stream.read()
if charset:
return data.decode(charset)
return data
return None