import git
repo = git.Repo(repo_dir)
ref_name = 'master'
for commit in repo.iter_commits(rev=ref_name):
<some code here>
Run Code Online (Sandbox Code Playgroud)
此代码迭代所有提交。我想迭代黑白 2 次提交。就像git log commit1...commit2
我如何使用 GitPython 的 iter_commits() 方法执行相同的操作。