Github API, 如何使用 blob

Github API, how to use blobs

为了了解 blob 在 Github API 中的工作原理,我尝试创建一个 blob 并在下面的海报中显示,我在响应中创建了 201,但在我的 github 存储库 我对这个 blob 只字未提。我不明白 blob 在这里是如何工作的,我对 blob 的预期功能是它允许我将文件推送到存储库,基本上我想要实现的是使用 github API 推送文件到存储库,如何使用 blob API?

my expected function of the blob is that it allows me to push a file to the repository

Git 从不推送文件。它推动 提交 。 Git blob 非常低级。

我认为您使用了错误的 API 端点。 contents endpoint lets you create files:

Create a file

This method creates a new file in a repository

PUT /repos/:owner/:repo/contents/:path

Parameters

  • path (string, required): The content path
  • message (string, required): The commit message
  • content (string, required): The new file content, Base64 encoded
  • branch (string): the branch name. Default: the repository’s default branch (usually master)

Optional Parameters

You can provide an additional committer parameter, which is an object containing information about the committer. Or, you can provide an author parameter, which is an object containing information about the author.