不能按照蟒蛇git的教程

问题描述:

最近我安装的python-git的包,并试图按照教程上通过以下链接的时候,我发现某些方法缺少...不能按照蟒蛇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 
>>> 
+0

我在看教程的过时版本吗? – deostroll 2012-07-07 18:12:39

这些命令适用于我,所以我同意你可能使用过时版本的其他答案。如果你在Linux和有PIP,安装,在命令行中,你可以这样做:

pip install --upgrade GitPython 

升级到最新版本。 (旁注:对于我在Fedora上,命令实际上是pip-python,所以它取决于你的发行版)。

这很可能是你使用的GitPython一个非常过时verison。在版本0.3中,is_dirty是一种方法,存在init

在0.1版中,is_dirtyproperty,并且init_bare被定义,但不是init

+0

我从Ubuntu的软件中心得到了这个...而且版本已经过时了! – deostroll 2012-07-07 18:25:22