Repositories - Create
在小組專案中建立 Git 存放庫。
POST https://dev.azure.com/{organization}/{project}/_apis/git/repositories?api-version=5.0
POST https://dev.azure.com/{organization}/{project}/_apis/git/repositories?sourceRef={sourceRef}&api-version=5.0
URI 參數
| 名稱 | 位於 | 必要 | 類型 | Description |
|---|---|---|---|---|
|
organization
|
path | True |
string |
Azure DevOps 組織的名稱。 |
|
project
|
path |
string |
專案識別碼或專案名稱 |
|
|
api-version
|
query | True |
string |
要使用的 API 版本。 這應該設定為 '5.0' 以使用此版本的 API。 |
|
source
|
query |
string |
[選擇性]指定建立分叉存放庫時要使用的來源 refs |
要求本文
| 名稱 | 類型 | Description |
|---|---|---|
| name |
string |
|
| parentRepository | ||
| project |
表示 TeamProject 的淺層參考。 |
回應
| 名稱 | 類型 | Description |
|---|---|---|
| 201 Created |
建立時間 |
安全性
oauth2
類型:
oauth2
Flow:
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
範圍
| 名稱 | Description |
|---|---|
| vso.code_manage | 授與讀取、更新和刪除原始程式碼、存取認可、變更集、分支和其他版本控制成品的相關中繼資料。 也授與建立和管理程式碼存放庫的能力、建立和管理提取要求和程式碼檢閱,以及透過服務勾點接收版本控制事件的通知。 |
範例
範例要求
POST https://dev.azure.com/fabrikam/_apis/git/repositories?api-version=5.0
{
"name": "AnotherRepository",
"project": {
"id": "6ce954b1-ce1f-45d1-b94d-e6bf2464ba2c"
}
}
範例回覆
{
"id": "5febef5a-833d-4e14-b9c0-14cb638f91e6",
"name": "AnotherRepository",
"url": "https://dev.azure.com/fabrikam/_apis/git/repositories/5febef5a-833d-4e14-b9c0-14cb638f91e6",
"project": {
"id": "6ce954b1-ce1f-45d1-b94d-e6bf2464ba2c",
"name": "Fabrikam-Fiber-Git",
"url": "https://dev.azure.com/fabrikam/_apis/projects/6ce954b1-ce1f-45d1-b94d-e6bf2464ba2c",
"state": "wellFormed"
},
"remoteUrl": "https://dev.azure.com/fabrikam/Fabrikam-Fiber-Git/_git/AnotherRepository"
}
定義
| 名稱 | Description |
|---|---|
|
Git |
|
|
Git |
|
|
Git |
|
|
Project |
專案狀態。 |
|
Project |
專案可見度。 |
|
Reference |
表示 REST 參考連結集合的類別。 |
|
Team |
TeamProjectCollection 的參考物件。 |
|
Team |
表示 TeamProject 的淺層參考。 |
GitRepository
| 名稱 | 類型 | Description |
|---|---|---|
| _links |
表示 REST 參考連結集合的類別。 |
|
| defaultBranch |
string |
|
| id |
string |
|
| isFork |
boolean |
True 是表示 如果存放庫已建立為分叉 |
| name |
string |
|
| parentRepository | ||
| project |
表示 TeamProject 的淺層參考。 |
|
| remoteUrl |
string |
|
| size |
integer |
存放庫的壓縮大小 (位元組) 。 |
| sshUrl |
string |
|
| url |
string |
|
| validRemoteUrls |
string[] |
GitRepositoryCreateOptions
| 名稱 | 類型 | Description |
|---|---|---|
| name |
string |
|
| parentRepository | ||
| project |
表示 TeamProject 的淺層參考。 |
GitRepositoryRef
| 名稱 | 類型 | Description |
|---|---|---|
| collection |
此分支所在的 Team 專案集合 |
|
| id |
string |
|
| isFork |
boolean |
True 是表示 如果存放庫已建立為分叉 |
| name |
string |
|
| project |
表示 TeamProject 的淺層參考。 |
|
| remoteUrl |
string |
|
| sshUrl |
string |
|
| url |
string |
ProjectState
專案狀態。
| 值 | Description |
|---|---|
| all |
不論狀態為何,所有專案。 |
| createPending |
專案已排入佇列以建立,但程式尚未啟動。 |
| deleted |
專案已刪除。 |
| deleting |
Project 正在刪除。 |
| new |
Project 正在建立中。 |
| unchanged |
專案尚未變更。 |
| wellFormed |
Project 已完全建立並可供使用。 |
ProjectVisibility
專案可見度。
| 值 | Description |
|---|---|
| private |
只有具有明確存取權的使用者才能看到專案。 |
| public |
專案對全部可見。 |
ReferenceLinks
表示 REST 參考連結集合的類別。
| 名稱 | 類型 | Description |
|---|---|---|
| links |
object |
連結的唯讀檢視。 因為參考連結是唯讀的,所以我們只想要將它們公開為唯讀。 |
TeamProjectCollectionReference
TeamProjectCollection 的參考物件。
| 名稱 | 類型 | Description |
|---|---|---|
| id |
string |
集合識別碼。 |
| name |
string |
集合名稱。 |
| url |
string |
集合 REST URL。 |
TeamProjectReference
表示 TeamProject 的淺層參考。
| 名稱 | 類型 | Description |
|---|---|---|
| abbreviation |
string |
專案縮寫。 |
| defaultTeamImageUrl |
string |
預設小組身分識別影像的 URL。 |
| description |
string |
如果有任何) ,專案的描述 (。 |
| id |
string |
專案識別碼。 |
| name |
string |
專案名稱。 |
| revision |
integer |
專案修訂。 |
| state |
專案狀態。 |
|
| url |
string |
物件完整版本的 URL。 |
| visibility |
專案可見度。 |