Repositories - Create

チーム プロジェクトに Git リポジトリを作成します。

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 パラメーター

Name / 必須 型 説明
organization
path True

string

Azure DevOps 組織の名前。

project
path

string

プロジェクト ID またはプロジェクト名

api-version
query True

string

使用する API のバージョン。 このバージョンの API を使用するには、これを '7.1' に設定する必要があります。

sourceRef
query

string

[省略可能]フォーク リポジトリの作成時に使用するソース参照を指定する

要求本文

Name 型 説明
name

string

parentRepository

GitRepositoryRef

project

TeamProjectReference

TeamProject への浅い参照を表します。

応答

Name 型 説明
201 Created

GitRepository

作成

セキュリティ

oauth2

型: oauth2
フロー: accessCode
Authorization URL (承認 URL): https://app.vssps.visualstudio.com/oauth2/authorize&response_type=Assertion
Token URL (トークン 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

スコープ

Name 説明
vso.code_manage ソース コードの読み取り、更新、削除、コミット、変更セット、ブランチ、およびその他のバージョン管理成果物に関するメタデータへのアクセスを許可します。 また、コード リポジトリの作成と管理、プル要求とコード レビューの作成と管理、サービス フックを介したバージョン管理イベントに関する通知の受信を行う機能も付与されます。

例

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

要求のサンプル

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"
    }
  }
}

応答のサンプル

{
  "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

要求のサンプル

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"
    }
  }
}

応答のサンプル

{
  "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

要求のサンプル

POST https://dev.azure.com/fabrikam/_apis/git/repositories?api-version=7.1

{
  "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"
}

定義

Name 説明
GitRepository
GitRepositoryCreateOptions
GitRepositoryRef
ProjectState

プロジェクトの状態。

ProjectVisibility

プロジェクトの可視性。

ReferenceLinks

REST 参照リンクのコレクションを表すクラス。

TeamProjectCollectionReference

TeamProjectCollection の参照オブジェクト。

TeamProjectReference

TeamProject への浅い参照を表します。

GitRepository

Name 型 説明
_links

ReferenceLinks

REST 参照リンクのコレクションを表すクラス。

defaultBranch

string

id

string (uuid)

isDisabled

boolean

True の 場合は、リポジトリが無効です。 それ以外の場合は False。

isFork

boolean

True の 場合は、リポジトリがフォークとして作成されました。

isInMaintenance

boolean

True の 場合は、リポジトリがメンテナンス中です。 それ以外の場合は False。

name

string

parentRepository

GitRepositoryRef

project

TeamProjectReference

TeamProject への浅い参照を表します。

remoteUrl

string

size

integer (int64)

リポジトリの圧縮サイズ (バイト)。

sshUrl

string

url

string

validRemoteUrls

string[]

webUrl

string

GitRepositoryCreateOptions

Name 型 説明
name

string

parentRepository

GitRepositoryRef

project

TeamProjectReference

TeamProject への浅い参照を表します。

GitRepositoryRef

Name 型 説明
collection

TeamProjectCollectionReference

このフォークが存在する Team Project Collection

id

string (uuid)

isFork

boolean

True リポジトリがフォークとして作成された場合

name

string

project

TeamProjectReference

TeamProject への浅い参照を表します。

remoteUrl

string

sshUrl

string

url

string

ProjectState

プロジェクトの状態。

値 説明
deleting

プロジェクトは削除中です。

new

プロジェクトは作成中です。

wellFormed

プロジェクトが完全に作成され、使用する準備が整いました。

createPending

プロジェクトは作成のためにキューに登録されていますが、プロセスはまだ開始されていません。

all

[削除済み] を除く、状態に関係なく、すべてのプロジェクト。

unchanged

プロジェクトは変更されていません。

deleted

プロジェクトが削除されました。

ProjectVisibility

プロジェクトの可視性。

値 説明
private

プロジェクトは、明示的なアクセス権を持つユーザーにのみ表示されます。

public

プロジェクトはすべてのユーザーに表示されます。

REST 参照リンクのコレクションを表すクラス。

Name 型 説明
links

object

リンクの読み取りビュー。 参照リンクは読み取り専用であるため、読み取り専用として公開する必要があります。

TeamProjectCollectionReference

TeamProjectCollection の参照オブジェクト。

Name 型 説明
avatarUrl

string

コレクションアバターの URL。

id

string (uuid)

コレクション ID。

name

string

コレクション名。

url

string

コレクション REST URL。

TeamProjectReference

TeamProject への浅い参照を表します。

Name 型 説明
abbreviation

string

プロジェクトの省略形。

defaultTeamImageUrl

string

既定のチーム ID イメージの URL。

description

string

プロジェクトの説明 (ある場合)。

id

string (uuid)

プロジェクト識別子。

lastUpdateTime

string (date-time)

プロジェクトの最終更新時刻。

name

string

プロジェクト名。

revision

integer (int64)

プロジェクトのリビジョン。

state

ProjectState

プロジェクトの状態。

url

string

オブジェクトの完全なバージョンへの URL。

visibility

ProjectVisibility

プロジェクトの可視性。