如何使用 GitHub API 获取任何分支中的一个文件的提交历史记录?

How to get commit history for just one file in any branch using GitHub APIs?

我尝试了以下端点,但它只是 returns 最新的提交。我想获得涉及我的文件的所有提交的列表。有什么方法可以使用 github api 来做到这一点吗?

我尝试过的端点: https://api.github.com/repos/:owner/:repo/commits/heads/:branch_name?path=file/path.py

要获取特定分支上特定文件路径的完整历史记录,请使用:

https://api.github.com/repos/:owner/:repo/commits?path=path/to/file.py&sha=master

例如:https://api.github.com/repos/torvalds/linux/commits?path=CREDITS&sha=master