Skip to main content

Get a tree

Returns a single tree using the SHA1 value for that tree. If `truncated` is `true` in the response then the number of items in the `tree` array exceeded our maximum limit. If you need to fetch more items, use the non-recursive method of fetching trees, and fetch one sub-tree at a time.

GET/repos/{owner}/{repo}/git/trees/{tree_sha}
Source
github-v3-rest.json
Revision
f5f067c1e6f6
Active snapshot
85e53e3d0d65

Request

Path Parameters
owner string
required
repo string
required
tree_sha string
required
Query Parameters
recursive string
optional

Setting this parameter to any value returns the objects or subtrees referenced by the tree specified in `:tree_sha`. For example, setting `recursive` to any of the following will enable returning objects or subtrees: `0`, `1`, `"true"`, and `"false"`. Omit this parameter to prevent recursively returning objects or subtrees.

Responses

application/json Git Tree object

Response

sha string
required
tree array[object]
required

Objects specifying a tree structure

Example:
[
  {
    "mode": "100644",
    "path": "file.rb",
    "properties": {
      "mode": {
        "type": "string"
      },
      "path": {
        "type": "string"
      },
      "sha": {
        "type": "string"
      },
      "size": {
        "type": "integer"
      },
      "type": {
        "type": "string"
      },
      "url": {
        "type": "string"
      }
    },
    "required": [
      "path",
      "mode",
      "type",
      "sha",
      "url",
      "size"
    ],
    "sha": "44b4fc6d56897b048c772eb4087f854f46256132",
    "size": 30,
    "type": "blob",
    "url": "https://api.github.com/repos/octocat/Hello-World/git/blobs/44b4fc6d56897b048c772eb4087f854f46256132"
  }
]
items object
mode string
optional

Example: 040000

path string
optional

Example: test/file.rb

sha string
optional

Example: 23f6827669e43831def8a7ad935069c8bd418261

size integer
optional

Example: 12

type string
optional

Example: tree

url string
optional
Example:
https://api.github.com/repos/owner-482f3203ecf01f67e9deb18e/BBB_Private_Repo/git/blobs/23f6827669e43831def8a7ad935069c8bd418261
truncated boolean
required
url string<uri>
required
application/json Basic Error object

Resource not found

documentation_url string
optional
message string
optional
status string
optional
url string
optional
application/json Validation Error object

Validation failed

documentation_url string
required
errors array[object]
optional
items object
code string
required
field string
optional
index integer
optional
message string
optional
resource string
optional
value
optional
message string
required