Are we able to use GitHub API to create a commit? especially v4?

后端 未结 1 1734
-上瘾入骨i
-上瘾入骨i 2020-12-20 02:06

Are we able to use GitHub API to create a commit? Can we use API to upload a file/blob, like what we can do using Git command, especially in API v4?

相关标签:
1条回答
  • 2020-12-20 02:10

    Presumably yes, using the GitHub Commits API (in the context of a GitHub application)

    You can see the all sequence in "GitHub API Git Data":

    • Get the current commit object
    • Retrieve the tree it points to
    • Retrieve the content of the blob object that tree has for that particular file path
    • Change the content somehow and post a new blob object with that new content, getting a blob SHA back
    • Post a new tree object with that file path pointer replaced with your new blob SHA getting a tree SHA back
    • Create a new commit object with the current commit SHA as the parent and the new tree SHA, getting a commit SHA back
    • Update the reference of your branch to point to the new commit SHA

    Each of those steps has its own GitHub API query.

    0 讨论(0)
提交回复
热议问题