Repositories - Create
Create a git repository in a team project.
POST https://dev.azure.com/{organization}/{project}/_apis/git/repositories?api-version=7.1
POST https://dev.azure.com/{organization}/{project}/_apis/git/repositories?sourceRef={sourceRef}&api-version=7.1
URI Parameters
Name | In | Required | Type | Description |
---|---|---|---|---|
organization
|
path | True |
string |
The name of the Azure DevOps organization. |
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.1' to use this version of the api. |
source
|
query |
string |
[optional] Specify the source refs to use while creating a fork repo |
Request Body
Name | Type | Description |
---|---|---|
name |
string |
|
parentRepository | ||
project |
Represents a shallow reference to a TeamProject. |
Responses
Name | Type | Description |
---|---|---|
201 Created |
Created |
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_manage | Grants the ability to read, update, and delete source code, access metadata about commits, changesets, branches, and other version control artifacts. Also grants the ability to create and manage code repositories, create and manage pull requests and code reviews, and to receive notifications about version control events via service hooks. |
Examples
Create a fork of a parent repository |
Create a fork of a parent repository syncing only the provided refs |
Create a repository |
Create a fork of a parent repository
Sample request
POST https://dev.azure.com/{organization}/_apis/git/repositories?api-version=7.1
{
"name": "forkRepository",
"project": {
"id": "3b046b6a-d070-4cd5-ad59-2eace5d05b90"
},
"parentRepository": {
"id": "57a09b16-c635-4ec9-bd6b-d501fec4eb7b",
"project": {
"id": "3b046b6a-d070-4cd5-ad59-2eace5d05b90"
}
}
}
Sample response
{
"id": "76b510af-7910-4a96-9902-b978d6226bee",
"name": "forkRepository",
"url": "https://dev.azure.com/fabrikam/MyFirstProject/_apis/git/repositories/76b510af-7910-4a96-9902-b978d6226bee",
"project": {
"id": "3b046b6a-d070-4cd5-ad59-2eace5d05b90",
"name": "MyFirstProject",
"url": "https://dev.azure.com/fabrikam/_apis/projects/3b046b6a-d070-4cd5-ad59-2eace5d05b90",
"state": "wellFormed",
"revision": 11,
"visibility": "private",
"defaultTeamImageUrl": null
},
"size": 0,
"remoteUrl": "https://dev.azure.com/fabrikam/MyFirstProject/_git/forkRepository",
"sshUrl": "git@ssh.dev.azure.com:v3/fabrikam/MyFirstProject/forkRepository",
"isFork": true,
"_links": {
"forkSyncOperation": {
"href": "https://dev.azure.com/fabrikam/_apis/git/repositories/76b510af-7910-4a96-9902-b978d6226bee/forkSyncRequests/8"
}
}
}
Create a fork of a parent repository syncing only the provided refs
Sample request
POST https://dev.azure.com/{organization}/_apis/git/repositories?sourceRef=users/heads/master&api-version=7.1
{
"name": "forkRepositoryWithOnlySourceRef",
"project": {
"id": "3b046b6a-d070-4cd5-ad59-2eace5d05b90"
},
"parentRepository": {
"id": "76b510af-7910-4a96-9902-b978d6226bee",
"project": {
"id": "3b046b6a-d070-4cd5-ad59-2eace5d05b90"
}
}
}
Sample response
{
"id": "29230c30-9125-459b-a3f6-ffab329053bd",
"name": "forkRepositoryWithOnlySourceRef",
"url": "https://dev.azure.com/fabrikam/MyFirstProject/_apis/git/repositories/29230c30-9125-459b-a3f6-ffab329053bd",
"project": {
"id": "3b046b6a-d070-4cd5-ad59-2eace5d05b90",
"name": "MyFirstProject",
"url": "https://dev.azure.com/fabrikam/_apis/projects/3b046b6a-d070-4cd5-ad59-2eace5d05b90",
"state": "wellFormed",
"revision": 12,
"visibility": "private",
"defaultTeamImageUrl": null
},
"size": 0,
"remoteUrl": "https://dev.azure.com/fabrikam/MyFirstProject/_git/forkRepositoryWithOnlySourceRef",
"sshUrl": "git@ssh.dev.azure.com:v3/fabrikam/MyFirstProject/forkRepositoryWithOnlySourceRef",
"isFork": true,
"_links": {
"forkSyncOperation": {
"href": "https://dev.azure.com/fabrikam/_apis/git/repositories/29230c30-9125-459b-a3f6-ffab329053bd/forkSyncRequests/7"
}
}
}
Create a repository
Sample request
POST https://dev.azure.com/fabrikam/_apis/git/repositories?api-version=7.1
{
"name": "AnotherRepository",
"project": {
"id": "6ce954b1-ce1f-45d1-b94d-e6bf2464ba2c"
}
}
Sample response
{
"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"
}
Definitions
Name | Description |
---|---|
Git |
|
Git |
|
Git |
|
Project |
Project state. |
Project |
Project visibility. |
Reference |
The class to represent a collection of REST reference links. |
Team |
Reference object for a TeamProjectCollection. |
Team |
Represents a shallow reference to a TeamProject. |
GitRepository
Name | Type | Description |
---|---|---|
_links |
The class to represent a collection of REST reference links. |
|
defaultBranch |
string |
|
id |
string |
|
isDisabled |
boolean |
True if the repository is disabled. False otherwise. |
isFork |
boolean |
True if the repository was created as a fork. |
isInMaintenance |
boolean |
True if the repository is in maintenance. False otherwise. |
name |
string |
|
parentRepository | ||
project |
Represents a shallow reference to a TeamProject. |
|
remoteUrl |
string |
|
size |
integer |
Compressed size (bytes) of the repository. |
sshUrl |
string |
|
url |
string |
|
validRemoteUrls |
string[] |
|
webUrl |
string |
GitRepositoryCreateOptions
Name | Type | Description |
---|---|---|
name |
string |
|
parentRepository | ||
project |
Represents a shallow reference to a TeamProject. |
GitRepositoryRef
Name | Type | Description |
---|---|---|
collection |
Team Project Collection where this Fork resides |
|
id |
string |
|
isFork |
boolean |
True if the repository was created as a fork |
name |
string |
|
project |
Represents a shallow reference to a TeamProject. |
|
remoteUrl |
string |
|
sshUrl |
string |
|
url |
string |
ProjectState
Project state.
Name | Type | Description |
---|---|---|
all |
string |
All projects regardless of state except Deleted. |
createPending |
string |
Project has been queued for creation, but the process has not yet started. |
deleted |
string |
Project has been deleted. |
deleting |
string |
Project is in the process of being deleted. |
new |
string |
Project is in the process of being created. |
unchanged |
string |
Project has not been changed. |
wellFormed |
string |
Project is completely created and ready to use. |
ProjectVisibility
Project visibility.
Name | Type | Description |
---|---|---|
private |
string |
The project is only visible to users with explicit access. |
public |
string |
The project is visible to all. |
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. |
TeamProjectCollectionReference
Reference object for a TeamProjectCollection.
Name | Type | Description |
---|---|---|
avatarUrl |
string |
Collection avatar Url. |
id |
string |
Collection Id. |
name |
string |
Collection Name. |
url |
string |
Collection REST Url. |
TeamProjectReference
Represents a shallow reference to a TeamProject.
Name | Type | Description |
---|---|---|
abbreviation |
string |
Project abbreviation. |
defaultTeamImageUrl |
string |
Url to default team identity image. |
description |
string |
The project's description (if any). |
id |
string |
Project identifier. |
lastUpdateTime |
string |
Project last update time. |
name |
string |
Project name. |
revision |
integer |
Project revision. |
state |
Project state. |
|
url |
string |
Url to the full version of the object. |
visibility |
Project visibility. |