2

在查看位于此处的 gitpython 教程时,我的机器上存在一些问题。环境是 Windows 7,git 版本 1.7.11.msysgit.1 以及 Python 2.7。使用 easy_install 安装一切正常。Repo 对象成功创建,命令repo.tree()repo.branches工作一样。如果我这样做repo.is_dirty(),则会出现未找到非特定文件的错误。 WindowsError: [Error 2] The system cannot find the file specified.有任何想法吗?

path = "c:\\path_to_repo"
repo = Repo(path)
assert repo.bare == False
print repo.tree()

repo.branches

print dir(repo)

#these always crash...
repo.is_dirty()

TIA 寻求帮助。

4

1 回答 1

2

git.ext您可能没有PATH,但可以通过自己执行轻松测试。如果您看到错误,您可以将其添加到PATH,或将 设置为GIT_PYTHON_GIT_EXECUTABLEgit-python 应该为 git 命令行服务执行的可执行文件。

它适用于.tree()相关对象查询的原因是 gitpython 为这些操作使用纯 python 后端。默认情况下,更复杂.is_dirty()的操作仍然需要 git 可执行文件。PATH

于 2015-01-27T21:05:07.820 回答