python - 在 gitpython 中获取特定文件的所有修订

标签 python git gitpython

我正在使用 gitpython用于执行 git 操作的库,从 python 代码中检索 git 信息。我想检索特定文件的所有修订。但是在 docs 上找不到具体的引用资料.

谁能提供一些线索,说明哪个函数在这方面有帮助?谢谢。

最佳答案

后续,读取每个文件:

import git
repo = git.Repo()
path = "file_you_are_looking_for"

revlist = (
    (commit, (commit.tree / path).data_stream.read())
    for commit in repo.iter_commits(paths=path)
)

for commit, filecontents in revlist:
    ...

关于python - 在 gitpython 中获取特定文件的所有修订,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28803626/

相关文章:

python - Pyramid 遍历HTTP PUT到不存在的URI

python - 是否可以在日期时间集合上使用 cut?

git - 使用 Travis CI 和 Capistrano 持续部署到 VPS 的良好工作流程是什么?

python - GitPython:在运行时设置 git 可执行文件

python - 如何使用 gitpython 获取提交作者姓名和电子邮件?

python-3.x - 如何使用 gitpython 在远程获取最新的提交哈希?

python - 删除数据框中每个 ID 的前 n 行

python - 单击 'submit' 时如何获取下载的 pdf 文件,这也会将我重定向到新页面

ruby - GitHub API : Tag a commit belongs to ( parallel for git describe --tag <sha> )

git - 如何解决git中的冲突?