This version of GitHub Enterprise was discontinued on 2021-03-02. No patch releases will be made, even for critical security issues. For better performance, improved security, and new features, upgrade to the latest version of GitHub Enterprise. For help with the upgrade, contact GitHub Enterprise support.

Git database

In this article

The Git Database API gives you access to read and write raw Git objects to your Git database on GitHub Enterprise Server and to list and update your references (branch heads and tags). For more information about using the Git Database API, see "Getting started with the Git data API."

Blobs

A Git blob (binary large object) is the object type used to store the contents of each file in a repository. The file's SHA-1 hash is computed and stored in the blob object. These endpoints allow you to read and write blob objects to your Git database on GitHub Enterprise Server. Blobs leverage these custom media types. You can read more about the use of media types in the API here.

Custom media types for blobs

These are the supported media types for blobs.

application/json
application/vnd.github.VERSION.raw

For more information, see "Media types."

post /repos/{owner}/{repo}/git/blobs

Parameters

Name Type In Description
accept string header

Setting to application/vnd.github.v3+json is recommended.

owner string path
repo string path
content string body

Required. The new blob's content.

encoding string body

The encoding used for content. Currently, "utf-8" and "base64" are supported.

Default: utf-8

Code samples

Shell
curl \
  -X POST \
  -H "Accept: application/vnd.github.v3+json" \
  http(s)://{hostname}/api/v3/repos/octocat/hello-world/git/blobs \
  -d '{"content":"content"}'
JavaScript (@octokit/core.js)
await octokit.request('POST /repos/{owner}/{repo}/git/blobs', {
  owner: 'octocat',
  repo: 'hello-world',
  content: 'content'
})

Default response

Status: 201 Created
{
  "url": "https://api.github.com/repos/octocat/example/git/blobs/3a0f86fb8db8eea7ccbb9a95f325ddbedfb25e15",
  "sha": "3a0f86fb8db8eea7ccbb9a95f325ddbedfb25e15"
}

Forbidden

Status: 403 Forbidden

Resource not found

Status: 404 Not Found

Conflict

Status: 409 Conflict

Validation failed

Status: 422 Unprocessable Entity

Notes


Get a blob

The content in the response will always be Base64 encoded.

Note: This API supports blobs up to 100 megabytes in size.

get /repos/{owner}/{repo}/git/blobs/{file_sha}

Parameters

Name Type In Description
accept string header

Setting to application/vnd.github.v3+json is recommended.

owner string path
repo string path
file_sha string path