Git python 从给定的 sha 提交 id 中提取所有后续提交的脚本

Git python script to extract all the later commits from a given sha commit id

我正在尝试使用 Python 在特定开始提交后从分支中提取所有提交消息的列表。我无法从 GITPython api 中找到任何有用的函数,或者我只是错过了它。有人可以指导我吗?

您可能想尝试 PyDriller,它更简单:

for commit in RepositoryMining("path_to_repo", from_commit="STARTING COMMIT").traverse_commits():
    print(commit.msg)

如果要提交特定分支,请添加参数only_in_branch="BRANCH_NAME"。文档:http://pydriller.readthedocs.io/en/latest/

我还建议尝试在 git 和 lizard 之上开发的 PyDriller。您可以提取有关提交的所有大量信息,而不仅仅是提交消息。

for commit in RepositoryMining("path_to_repo").traverse_commits():
        print(commit.msg)
        print(commit.hash)
        print(commit.author)
        print(commit.project_name)

以及更多选项。如果你想使用 Python 包 - git 和 lizard。一些有用的链接是 - https://medium.com/@deepakr6242/using-python-to-extract-files-from-git-hub-repo-through-commits-id-2bdf76b2e0fd https://www.pylabz.com/2019/08/using-python-to-pull-files-of-git-hub.html