git-python从仓库获取提交提要 [英] git-python get commit feed from a repository

查看:492
本文介绍了git-python从仓库获取提交提要的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在研究一个代码,我想从github上的存储库中检索提交。我不完全确定如何做这样的事情,我得到了git-python,但大多数API是用于在同一文件系统上打开本地git存储库。

可以有人建议吗?

问候,

解决方案

使用命令行(我假设Linux或任何其他Unix在这里,但在Windows上应该是相同的)先克隆现有的存储库:



git clone git:/ /github.com/forsberg/misctools.git



这将创建 misctools 目录。



现在,从python开始,您可以打开这个存储库并使用pull进行更新:

 #!/ usr / bin / env python 

from git import *

repo = Repo(misctools)
o = repo.remotes .origin
o.pull()

master = repo.head.reference
print master.log()

全部记录在 http://packages.python.org/GitPython/0.3.2/tutorial.html


am working on a code which I would like to retrieve the commits from a repository on github. Am not entirely sure how to do such a thing, I got git-python but most the api's are for opening a local git repository on the same file system.

Can someone advice?

regards,

解决方案

It seems the easiest thing here is to use the commandline (I'm assuming Linux or any other Unix here, but should be the same on Windows) to clone an existing repository first:

git clone git://github.com/forsberg/misctools.git

This will create the misctools directory.

Now, from python, you can open this repository and update it using pull:

#!/usr/bin/env python

from git import *

repo = Repo("misctools")
o = repo.remotes.origin
o.pull()

master = repo.head.reference
print master.log()

It's all documented at http://packages.python.org/GitPython/0.3.2/tutorial.html

这篇关于git-python从仓库获取提交提要的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆