使用GitPython并尝试打印日志:
print(self._git.log('{}..{} --pretty=tformat:%h:%s:%cn'.format(self.good, self.bad).split()))
其中:
self._repo = git.Repo(path=repo, search_parent_directories=True)
self._git = git.Git(self._repo.working_tree_dir)
并收到此错误
git.exc.GitCommandError: Cmd('git') failed due to: exit code(128)
cmdline: git log 7900edaa7973536bd53bea35404772b46735c46a..83bd42668003bb6075e44fd44ec21a39dd90096f --pretty=tformat:%h:%s:%cn
stderr: 'fatal: Invalid revision range 7900edaa7973536bd53bea35404772b46735c46a..83bd42668003bb6075e44fd44ec21a39dd90096f'
但是从bash的错误(即git log 7900edaa7973536bd53bea35404772b46735c46a..83bd42668003bb6075e44fd44ec21a39dd90096f --pretty=tformat:%h:%s:%cn
)运行命令时,我得到了正常结果。
当我用count(print(self._git.log('-4 --pretty=tformat:%h:%s:%cn'.split()))
)替换提交时,它确实起作用了
答案 0 :(得分:2)
这在test project中使用python 2.7.16和GitPython 2.1.14为我工作。
基于错误消息(无效的修订范围),我认为您的python代码使用的存储库与从Shell运行git
命令的存储库不同。