Trees - Get
The Tree endpoint returns the collection of objects underneath the specified tree. Trees are folders in a Git repository.
Repositories have both a name and an identifier. Identifiers are globally unique, but several projects may contain a repository of the same name. You don't need to include the project if you specify a repository by ID. However, if you specify a repository by name, you must also specify the project (by name or ID.
GET https://dev.azure.com/{organization}/{project}/_apis/git/repositories/{repositoryId}/trees/{sha1}?api-version=7.0
GET https://dev.azure.com/{organization}/{project}/_apis/git/repositories/{repositoryId}/trees/{sha1}?projectId={projectId}&recursive={recursive}&fileName={fileName}&$format={$format}&api-version=7.0
URI Parameters
Name | In | Required | Type | Description |
---|---|---|---|---|
organization
|
path | True |
string |
The name of the Azure DevOps organization. |
repository
|
path | True |
string |
Repository Id. |
sha1
|
path | True |
string |
SHA1 hash of the tree object. |
project
|
path |
string |
Project ID or project name |
|
api-version
|
query | True |
string |
Version of the API to use. This should be set to '7.0' to use this version of the api. |
$format
|
query |
string |
Use "zip". Defaults to the MIME type set in the Accept header. |
|
file
|
query |
string |
Name to use if a .zip file is returned. Default is the object ID. |
|
project
|
query |
string |
Project Id. |
|
recursive
|
query |
boolean |
Search recursively. Include trees underneath this tree. Default is false. |
Responses
Name | Type | Description |
---|---|---|
200 OK |
successful operation Media Types: "application/zip", "application/json" |
Security
oauth2
Type:
oauth2
Flow:
accessCode
Authorization URL:
https://app.vssps.visualstudio.com/oauth2/authorize&response_type=Assertion
Token URL:
https://app.vssps.visualstudio.com/oauth2/token?client_assertion_type=urn:ietf:params:oauth:client-assertion-type:jwt-bearer&grant_type=urn:ietf:params:oauth:grant-type:jwt-bearer
Scopes
Name | Description |
---|---|
vso.code | Grants the ability to read source code and metadata about commits, changesets, branches, and other version control artifacts. Also grants the ability to search code and get notified about version control events via service hooks. |
Examples
Non-recursive Example |
Recursive Example |
Non-recursive Example
Sample Request
GET https://dev.azure.com/fabrikam/_apis/git/repositories/278d5cd2-584d-4b63-824a-2ba458937249/trees/d1d5c2d49045d52bba6419652d6ecb2cd560dc29?api-version=7.0
Sample Response
{
"objectId": "d1d5c2d49045d52bba6419652d6ecb2cd560dc29",
"url": "https://dev.azure.com/fabrikam/_apis/git/repositories/278d5cd2-584d-4b63-824a-2ba458937249/trees/d1d5c2d49045d52bba6419652d6ecb2cd560dc29",
"treeEntries": [
{
"objectId": "ea6765e1976b9e8a6d4981fd8febebd574a91571",
"relativePath": "Home",
"mode": "40000",
"gitObjectType": "tree",
"url": "https://dev.azure.com/fabrikam/_apis/git/repositories/278d5cd2-584d-4b63-824a-2ba458937249/trees/ea6765e1976b9e8a6d4981fd8febebd574a91571",
"size": 259
},
{
"objectId": "d1c521e3b401b314d4f9ff17f6cad4652c6a4d14",
"relativePath": "Shared",
"mode": "40000",
"gitObjectType": "tree",
"url": "https://dev.azure.com/fabrikam/_apis/git/repositories/278d5cd2-584d-4b63-824a-2ba458937249/trees/d1c521e3b401b314d4f9ff17f6cad4652c6a4d14",
"size": 82
},
{
"objectId": "f5dd7df5872eae8c39c9491f67d856dafd609683",
"relativePath": "Web.config",
"mode": "100644",
"gitObjectType": "blob",
"url": "https://dev.azure.com/fabrikam/_apis/git/repositories/278d5cd2-584d-4b63-824a-2ba458937249/blobs/f5dd7df5872eae8c39c9491f67d856dafd609683",
"size": 1670
},
{
"objectId": "2de62418c07c3ffa833543f484445dbfd0fe68d8",
"relativePath": "_ViewStart.cshtml",
"mode": "100644",
"gitObjectType": "blob",
"url": "https://dev.azure.com/fabrikam/_apis/git/repositories/278d5cd2-584d-4b63-824a-2ba458937249/blobs/2de62418c07c3ffa833543f484445dbfd0fe68d8",
"size": 54
}
],
"size": 147,
"_links": {
"self": {
"href": "https://dev.azure.com/fabrikam/_apis/git/repositories/278d5cd2-584d-4b63-824a-2ba458937249/trees/d1d5c2d49045d52bba6419652d6ecb2cd560dc29"
},
"repository": {
"href": "https://dev.azure.com/fabrikam/_apis/git/repositories/278d5cd2-584d-4b63-824a-2ba458937249"
},
"treeEntries": [
{
"href": "https://dev.azure.com/fabrikam/_apis/git/repositories/278d5cd2-584d-4b63-824a-2ba458937249/trees/ea6765e1976b9e8a6d4981fd8febebd574a91571"
},
{
"href": "https://dev.azure.com/fabrikam/_apis/git/repositories/278d5cd2-584d-4b63-824a-2ba458937249/trees/d1c521e3b401b314d4f9ff17f6cad4652c6a4d14"
},
{
"href": "https://dev.azure.com/fabrikam/_apis/git/repositories/278d5cd2-584d-4b63-824a-2ba458937249/blobs/f5dd7df5872eae8c39c9491f67d856dafd609683"
},
{
"href": "https://dev.azure.com/fabrikam/_apis/git/repositories/278d5cd2-584d-4b63-824a-2ba458937249/blobs/2de62418c07c3ffa833543f484445dbfd0fe68d8"
}
]
}
}
Recursive Example
Sample Request
GET https://dev.azure.com/fabrikam/_apis/git/repositories/278d5cd2-584d-4b63-824a-2ba458937249/trees/d1d5c2d49045d52bba6419652d6ecb2cd560dc29?recursive=true&api-version=7.0
Sample Response
{
"objectId": "d1d5c2d49045d52bba6419652d6ecb2cd560dc29",
"url": "https://dev.azure.com/fabrikam/_apis/git/repositories/278d5cd2-584d-4b63-824a-2ba458937249/trees/d1d5c2d49045d52bba6419652d6ecb2cd560dc29",
"treeEntries": [
{
"objectId": "ea6765e1976b9e8a6d4981fd8febebd574a91571",
"relativePath": "Home",
"mode": "40000",
"gitObjectType": "tree",
"url": "https://dev.azure.com/fabrikam/_apis/git/repositories/278d5cd2-584d-4b63-824a-2ba458937249/trees/ea6765e1976b9e8a6d4981fd8febebd574a91571",
"size": 259
},
{
"objectId": "9093f030aa7dd8c802cad228fae4c6bafae4b32f",
"relativePath": "Home/Index.cshtml",
"mode": "100644",
"gitObjectType": "blob",
"url": "https://dev.azure.com/fabrikam/_apis/git/repositories/278d5cd2-584d-4b63-824a-2ba458937249/blobs/9093f030aa7dd8c802cad228fae4c6bafae4b32f",
"size": 2690
},
{
"objectId": "61a86fdaa79e5c6f5fb6e4026508489feb6ed92c",
"relativePath": "Home/_Home.cshtml",
"mode": "100644",
"gitObjectType": "blob",
"url": "https://dev.azure.com/fabrikam/_apis/git/repositories/278d5cd2-584d-4b63-824a-2ba458937249/blobs/61a86fdaa79e5c6f5fb6e4026508489feb6ed92c",
"size": 1486
},
{
"objectId": "445986f7957f0478686b6def4dcd04d2bad00594",
"relativePath": "Home/_Login.cshtml",
"mode": "100644",
"gitObjectType": "blob",
"url": "https://dev.azure.com/fabrikam/_apis/git/repositories/278d5cd2-584d-4b63-824a-2ba458937249/blobs/445986f7957f0478686b6def4dcd04d2bad00594",
"size": 2828
},
{
"objectId": "d95a992b555367d1332be5407ba653261543c190",
"relativePath": "Home/_Manage.cshtml",
"mode": "100644",
"gitObjectType": "blob",
"url": "https://dev.azure.com/fabrikam/_apis/git/repositories/278d5cd2-584d-4b63-824a-2ba458937249/blobs/d95a992b555367d1332be5407ba653261543c190",
"size": 5672
},
{
"objectId": "8052a02bee6f82ae02c4d408d1b5b98ab1bf56a6",
"relativePath": "Home/_Register.cshtml",
"mode": "100644",
"gitObjectType": "blob",
"url": "https://dev.azure.com/fabrikam/_apis/git/repositories/278d5cd2-584d-4b63-824a-2ba458937249/blobs/8052a02bee6f82ae02c4d408d1b5b98ab1bf56a6",
"size": 1475
},
{
"objectId": "d3ea8b1ffab4736168e4b1d225ebc5aa0ade8cfe",
"relativePath": "Home/_RegisterExternal.cshtml",
"mode": "100644",
"gitObjectType": "blob",
"url": "https://dev.azure.com/fabrikam/_apis/git/repositories/278d5cd2-584d-4b63-824a-2ba458937249/blobs/d3ea8b1ffab4736168e4b1d225ebc5aa0ade8cfe",
"size": 1106
},
{
"objectId": "d1c521e3b401b314d4f9ff17f6cad4652c6a4d14",
"relativePath": "Shared",
"mode": "40000",
"gitObjectType": "tree",
"url": "https://dev.azure.com/fabrikam/_apis/git/repositories/278d5cd2-584d-4b63-824a-2ba458937249/trees/d1c521e3b401b314d4f9ff17f6cad4652c6a4d14",
"size": 82
},
{
"objectId": "a89723ddddb14cd956fae1a6f118ba29f1667cf4",
"relativePath": "Shared/Error.cshtml",
"mode": "100644",
"gitObjectType": "blob",
"url": "https://dev.azure.com/fabrikam/_apis/git/repositories/278d5cd2-584d-4b63-824a-2ba458937249/blobs/a89723ddddb14cd956fae1a6f118ba29f1667cf4",
"size": 191
},
{
"objectId": "86b48073d8ce15039ce18219d8fda43ba7f0c467",
"relativePath": "Shared/_Layout.cshtml",
"mode": "100644",
"gitObjectType": "blob",
"url": "https://dev.azure.com/fabrikam/_apis/git/repositories/278d5cd2-584d-4b63-824a-2ba458937249/blobs/86b48073d8ce15039ce18219d8fda43ba7f0c467",
"size": 1627
},
{
"objectId": "f5dd7df5872eae8c39c9491f67d856dafd609683",
"relativePath": "Web.config",
"mode": "100644",
"gitObjectType": "blob",
"url": "https://dev.azure.com/fabrikam/_apis/git/repositories/278d5cd2-584d-4b63-824a-2ba458937249/blobs/f5dd7df5872eae8c39c9491f67d856dafd609683",
"size": 1670
},
{
"objectId": "2de62418c07c3ffa833543f484445dbfd0fe68d8",
"relativePath": "_ViewStart.cshtml",
"mode": "100644",
"gitObjectType": "blob",
"url": "https://dev.azure.com/fabrikam/_apis/git/repositories/278d5cd2-584d-4b63-824a-2ba458937249/blobs/2de62418c07c3ffa833543f484445dbfd0fe68d8",
"size": 54
}
],
"size": 147,
"_links": {
"self": {
"href": "https://dev.azure.com/fabrikam/_apis/git/repositories/278d5cd2-584d-4b63-824a-2ba458937249/trees/d1d5c2d49045d52bba6419652d6ecb2cd560dc29"
},
"repository": {
"href": "https://dev.azure.com/fabrikam/_apis/git/repositories/278d5cd2-584d-4b63-824a-2ba458937249"
},
"treeEntries": [
{
"href": "https://dev.azure.com/fabrikam/_apis/git/repositories/278d5cd2-584d-4b63-824a-2ba458937249/trees/ea6765e1976b9e8a6d4981fd8febebd574a91571"
},
{
"href": "https://dev.azure.com/fabrikam/_apis/git/repositories/278d5cd2-584d-4b63-824a-2ba458937249/blobs/9093f030aa7dd8c802cad228fae4c6bafae4b32f"
},
{
"href": "https://dev.azure.com/fabrikam/_apis/git/repositories/278d5cd2-584d-4b63-824a-2ba458937249/blobs/61a86fdaa79e5c6f5fb6e4026508489feb6ed92c"
},
{
"href": "https://dev.azure.com/fabrikam/_apis/git/repositories/278d5cd2-584d-4b63-824a-2ba458937249/blobs/445986f7957f0478686b6def4dcd04d2bad00594"
},
{
"href": "https://dev.azure.com/fabrikam/_apis/git/repositories/278d5cd2-584d-4b63-824a-2ba458937249/blobs/d95a992b555367d1332be5407ba653261543c190"
},
{
"href": "https://dev.azure.com/fabrikam/_apis/git/repositories/278d5cd2-584d-4b63-824a-2ba458937249/blobs/8052a02bee6f82ae02c4d408d1b5b98ab1bf56a6"
},
{
"href": "https://dev.azure.com/fabrikam/_apis/git/repositories/278d5cd2-584d-4b63-824a-2ba458937249/blobs/d3ea8b1ffab4736168e4b1d225ebc5aa0ade8cfe"
},
{
"href": "https://dev.azure.com/fabrikam/_apis/git/repositories/278d5cd2-584d-4b63-824a-2ba458937249/trees/d1c521e3b401b314d4f9ff17f6cad4652c6a4d14"
},
{
"href": "https://dev.azure.com/fabrikam/_apis/git/repositories/278d5cd2-584d-4b63-824a-2ba458937249/blobs/a89723ddddb14cd956fae1a6f118ba29f1667cf4"
},
{
"href": "https://dev.azure.com/fabrikam/_apis/git/repositories/278d5cd2-584d-4b63-824a-2ba458937249/blobs/86b48073d8ce15039ce18219d8fda43ba7f0c467"
},
{
"href": "https://dev.azure.com/fabrikam/_apis/git/repositories/278d5cd2-584d-4b63-824a-2ba458937249/blobs/f5dd7df5872eae8c39c9491f67d856dafd609683"
},
{
"href": "https://dev.azure.com/fabrikam/_apis/git/repositories/278d5cd2-584d-4b63-824a-2ba458937249/blobs/2de62418c07c3ffa833543f484445dbfd0fe68d8"
}
]
}
}
Definitions
Name | Description |
---|---|
Git |
Type of object (Commit, Tree, Blob, Tag) |
Git |
|
Git |
|
Reference |
The class to represent a collection of REST reference links. |
GitObjectType
Type of object (Commit, Tree, Blob, Tag)
Name | Type | Description |
---|---|---|
bad |
string |
|
blob |
string |
|
commit |
string |
|
ext2 |
string |
|
ofsDelta |
string |
|
refDelta |
string |
|
tag |
string |
|
tree |
string |
GitTreeEntryRef
Name | Type | Description |
---|---|---|
gitObjectType |
Blob or tree |
|
mode |
string |
Mode represented as octal string |
objectId |
string |
SHA1 hash of git object |
relativePath |
string |
Path relative to parent tree object |
size |
integer |
Size of content |
url |
string |
url to retrieve tree or blob |
GitTreeRef
Name | Type | Description |
---|---|---|
_links |
The class to represent a collection of REST reference links. |
|
objectId |
string |
SHA1 hash of git object |
size |
integer |
Sum of sizes of all children |
treeEntries |
Blobs and trees under this tree |
|
url |
string |
Url to tree |
ReferenceLinks
The class to represent a collection of REST reference links.
Name | Type | Description |
---|---|---|
links |
object |
The readonly view of the links. Because Reference links are readonly, we only want to expose them as read only. |
Feedback
https://aka.ms/ContentUserFeedback.
Coming soon: Throughout 2024 we will be phasing out GitHub Issues as the feedback mechanism for content and replacing it with a new feedback system. For more information see:Submit and view feedback for