在Github API中,是否可以获取一个文件的提交历史记录?

25

我希望能够在GitHub的REST API中获取某个文件的所有提交记录。但是我只能获取到某个分支的所有提交记录,尝试获取以下内容:

http://api.github.com/users/<username>/<project>/commits/<branch>/<path/to/file>

但这也没有帮助。这至少有可能吗?

2个回答

40

2
这里的分支怎么样? - Sameer Sawla
谁能读懂,谁就处于优势;)。https://developer.github.com/v3/repos/commits/#parameters - Martin Nowak
1
https://api.github.com/repos/{owner}/{repo}/commits?sha={branch}&path={path} - Ynjxsjmh

9
使用 GraphQL API v4,对于默认分支上的文件,应该是:
{
  repository(owner: "izuzak", name: "pmrpc") {
    defaultBranchRef{
      target {
        ...on Commit{
            history(first:100,path: "README.markdown"){
            nodes {
              author {
                email
              }
              message
              oid
            }
          }
        }
      }
    }
  }
}

在浏览器中尝试


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接