我最近安装了python-git包,当我尝试按照以下链接上的教程操作时,我发现缺少某些方法……
http://packages.python.org/GitPython/0.3.2/tutorial.html#tutorial-label
下面是我的翻译器输出的结果:
>>> from git import *
>>> repo = Repo.init('/home/deostroll/scripts/synchost')
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
AttributeError: type object 'Repo' has no attribute 'init'
>>> repo = Repo('/home/deostroll/scripts/synchost')
>>> repo.is_dirty()
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: 'bool' object is not callable
>>> 发布于 2012-07-08 02:29:17
这些命令对我有效,所以我同意另一个答案,即您使用的可能是过时的版本。如果您使用的是linux,并且安装了PIP,那么您可以在命令行上执行以下操作:
pip install --upgrade GitPython升级到最新版本。(旁注:对于我在Fedora上,该命令实际上是pip-python,因此这取决于您的发行版)。
https://stackoverflow.com/questions/11377444
复制相似问题