Trees - Get
树终结点返回指定树下的对象集合。 树是 Git 存储库中的文件夹。
存储库具有名称和标识符。 标识符全局唯一,但多个项目可能包含同名存储库。 如果按 ID 指定存储库,则无需包含项目。 但是,如果按名称指定存储库,则还必须指定项目(按名称或 ID)。
GET https://dev.azure.com/{organization}/{project}/_apis/git/repositories/{repositoryId}/trees/{sha1}?api-version=7.1
GET https://dev.azure.com/{organization}/{project}/_apis/git/repositories/{repositoryId}/trees/{sha1}?projectId={projectId}&recursive={recursive}&fileName={fileName}&$format={$format}&api-version=7.1
URI 参数
名称 | 在 | 必需 | 类型 | 说明 |
---|---|---|---|---|
organization
|
path | True |
string |
Azure DevOps 组织的名称。 |
repository
|
path | True |
string |
存储库 ID。 |
sha1
|
path | True |
string |
树对象的 SHA1 哈希。 |
project
|
path |
string |
项目 ID 或项目名称 |
|
api-version
|
query | True |
string |
要使用的 API 版本。 这应设置为“7.1”才能使用此版本的 API。 |
$format
|
query |
string |
使用“zip”。 默认为 Accept 标头中设置的 MIME 类型。 |
|
file
|
query |
string |
返回 .zip 文件时要使用的名称。 默认值为对象 ID。 |
|
project
|
query |
string |
项目 ID。 |
|
recursive
|
query |
boolean |
以递归方式搜索。 包括此树下的树。 默认值为 false。 |
响应
名称 | 类型 | 说明 |
---|---|---|
200 OK |
成功作 Media Types: "application/zip", "application/json" |
安全性
oauth2
类型:
oauth2
流向:
accessCode
授权 URL:
https://app.vssps.visualstudio.com/oauth2/authorize&response_type=Assertion
令牌 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
作用域
名称 | 说明 |
---|---|
vso.code | 授予读取有关提交、更改集、分支和其他版本控制项目的源代码和元数据的能力。 此外,还可以通过服务挂钩搜索代码并获取有关版本控制事件的通知。 |
示例
Non-recursive Example |
Recursive Example |
Non-recursive Example
示例请求
GET https://dev.azure.com/fabrikam/_apis/git/repositories/278d5cd2-584d-4b63-824a-2ba458937249/trees/d1d5c2d49045d52bba6419652d6ecb2cd560dc29?api-version=7.1
示例响应
{
"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
示例请求
GET https://dev.azure.com/fabrikam/_apis/git/repositories/278d5cd2-584d-4b63-824a-2ba458937249/trees/d1d5c2d49045d52bba6419652d6ecb2cd560dc29?recursive=true&api-version=7.1
示例响应
{
"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"
}
]
}
}
定义
名称 | 说明 |
---|---|
Git |
对象类型(提交、树、Blob、标记) |
Git |
|
Git |
|
Reference |
表示 REST 引用链接集合的类。 |
GitObjectType
对象类型(提交、树、Blob、标记)
值 | 说明 |
---|---|
bad | |
blob | |
commit | |
ext2 | |
ofsDelta | |
refDelta | |
tag | |
tree |
GitTreeEntryRef
名称 | 类型 | 说明 |
---|---|---|
gitObjectType |
Blob 或树 |
|
mode |
string |
表示为八进制字符串的模式 |
objectId |
string |
git 对象的 SHA1 哈希 |
relativePath |
string |
相对于父树对象的路径 |
size |
integer (int64) |
内容大小 |
url |
string |
用于检索树或 blob 的 URL |
GitTreeRef
名称 | 类型 | 说明 |
---|---|---|
_links |
表示 REST 引用链接集合的类。 |
|
objectId |
string |
git 对象的 SHA1 哈希 |
size |
integer (int64) |
所有子级的大小之和 |
treeEntries |
此树下的 Blob 和树 |
|
url |
string |
指向树的 URL |
ReferenceLinks
表示 REST 引用链接集合的类。
名称 | 类型 | 说明 |
---|---|---|
links |
object |
链接的只读视图。 由于引用链接是只读的,因此我们只想将其公开为只读链接。 |