我正在寻找使用 gitpython 来获取树上的数据..列出文件提交的时间和给出的日志..据我所知是
from git import *
repo = get_repo("/path/to/git/repo")
for item in repo.tree().items():
print item[1]
Run Code Online (Sandbox Code Playgroud)
那只是列出了诸如
<git.Tree "ac1dcd90a3e9e0c0359626f222b99c1df1f11175">
<git.Blob "764192de68e293d2372b2b9cd0c6ef868c682116">
<git.Blob "39fb4ae33f07dee15008341e10d3c37760b48d63">
<git.Tree "c32394851edcff4bf7a452f12cfe010e0ed43739">
<git.Blob "6a8e9935334278e4f38f9ec70f982cdc4f42abf0">
Run Code Online (Sandbox Code Playgroud)
我在 git.Blog 文档中没有看到您可以获取此数据的任何地方。
现在任何想要这样做的人都会是:
最后 100 个按降序排序:
repo.iter_commits('master', max_count=100)
您可以skip用于分页:
repo.iter_commits('master', max_count=10, skip=20)
参考:http : //gitpython.readthedocs.org/en/stable/tutorial.html#the-commit-object