git commit miss, 拿不到

git commit miss, can't get it

我克隆 'Apache/tomcat' git 存储库以使用一些关于提交的信息。

但是,当我使用 git.repo('repo local address').iter_commits() 时,我无法获得一些提交。 此外,我无法在 github 搜索引擎中搜索这些。

例如,commit 69c56080fb3355507e1b55d014ec0ee6767a6150 is in the 'Apache tomcat' repo, however, search '69c56080fb3355507e1b55d014ec0ee6767a6150' in 'in this repository'一无所获。 这对我来说太棒了。

好像commit不在master分支,所以搜索不到?

我想知道这背后的理论以及如何获取有关 Python 中这些 'missing' 提交的信息。

谢谢。

我认为这里的问题是这个提交在分支 8.5.x 而不是 master 中。您可以在第一个 link 中看到这一点。它将显示哪些分支包含它。 GitHub 搜索算法只搜索 master/main/trunk 分支。

要通过 git python 库找到它,请尝试切换到该分支。请参阅有关如何切换分支的说明:https://gitpython.readthedocs.io/en/stable/tutorial.html#switching-branches

repo.iter_commits(),不带参数,为您提供可以通过追溯当前提交的父级来达到的提交。换句话说,如果你在 master 分支中,它只会给你属于 master 分支的提交。

如果您需要获取分支列表,您可以给它一个 rev 参数,among other things, can be a branch name. For example, iter_commits(rev='8.5.x') ought to give you all commits in the 8.5.x branch, which will include 69c5608. You can use another function, repo.branches()

或者,如果您已经知道要查找的单个提交的哈希,您可以使用 repo.commit(),再次使用 rev 参数,在这种情况下是完整的或缩写的提交哈希:commit(rev='69c5608').