我开始使用 python 并尝试使用GitPython,我拼命尝试使用这个模块。
我在许多网站上看到文档很差,我遵循的示例似乎不起作用。
我在 Windows (2012/Python 3.5) 上试过这个:
# -*-coding:Latin-1 -*
from git import *
path = ('C:\\Users\\me\\Documents\\Repos\\integration')
repo = Repo(path)
assert repo.bare == False
repo.commits()
os.system("pause")
这在 Linux (Debian/Python 2.7) 上:
from git import Repo
repo = Repo('/home/git/repos/target_repos')
assert repo.bare == False
repo.commits ()
但无论如何,我没有结果......并以这个错误结束:
Traceback (most recent call last):
File "gitrepo.py", line 6, in <module>
repo.commits ()
AttributeError: 'Repo' object has no attribute 'commits'
在这两种情况下。
我的问题如下:
- 有没有办法让这个模块工作?我找到的所有链接都是旧的......
- 如果是,请帮助我或给我一个例子。
- 如果没有,是否还有另一个模块?我正在尝试安装 Dulwich,但没有成功(仅在 Windows 上)
- 我已经看到有一种使用fab的方法?是否可以用它来操纵 git ?
目标是将来用python管理git,以及其他东西进行集成。
谢谢您的回答。