【问题标题】:How to find all the git commit id's for all the branches using git hub rest api url如何使用 git hub rest api url 查找所有分支的所有 git commit id
【发布时间】:2018-06-28 06:28:21
【问题描述】:

我正在尝试使用 git hub rest api url 为所有分支提取提交 ID。但我只能看到最近的提交 id,看不到与一个分支相关的所有提交 id。

示例网址:https://api.github.com/repos/octocat/Hello-World/commits

请帮助我找到正确的 rest api url 来提取所有分支的所有提交 id。

【问题讨论】:

    标签: git rest api github gitlab


    【解决方案1】:

    仓库中所有提交的列表是分页的

    查看返回的标头 Link 以获取下一页和最后一页的 URL。

    从技术上讲,添加?page=<number> 进行查询。

    如果您只需要在某个分支中提交

    那是另一回事,我不相信 GitHub 提供了一种轻松遍历存储库的方法。您可能需要打开所需的参考:

    GET /repos/:owner/:repo/git/refs/:ref
    

    收集被引用对象的 SHA 并使用:

    GET /repos/:owner/:repo/git/commits/:commit_sha
    

    一路收集“父母”。

    【讨论】:

    猜你喜欢
    • 2019-11-09
    • 2018-04-26
    • 2019-11-20
    • 2011-08-20
    • 2011-11-25
    • 1970-01-01
    • 2022-01-09
    • 1970-01-01
    • 2021-02-26
    相关资源
    最近更新 更多