查看位于here 的教程时对于 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] 系统找不到指定的文件。有什么想法吗?
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 寻求任何帮助。
请您参考如下方法:
您可能没有 git.ext在你的PATH ,但这可以通过自己执行来轻松测试。如果您看到错误,您可以将其添加到 PATH ,或设置 GIT_PYTHON_GIT_EXECUTABLE到 git-python 应该为 git 命令行服务执行的可执行文件。
它适用于 .tree() 的原因和相关的对象查询是 gitpython 为这些操作使用纯 python 后端。更复杂的操作,如 .is_dirty()仍然需要 git 可执行文件在你的 PATH 中默认情况下。
