是否有可能在github api中获取一个文件的提交历史记录?

时间:2013-04-05 10:13:54

标签: github github-api

我想在github REST api中获取单独文件的所有提交消息。但我得到的只是 - 只获得所有提交单独的分支。然后我试着跟随:

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

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

2 个答案:

答案 0 :(得分:24)

答案 1 :(得分:3)

使用GraphQL API v4,对于默认分支上的文件,它将是:

{
  repository(owner: "izuzak", name: "pmrpc") {
    defaultBranchRef{
      target {
        ...on Commit{
            history(first:100,path: "README.markdown"){
            nodes {
              author {
                email
              }
              message
              oid
            }
          }
        }
      }
    }
  }
}

Try it in the explorer