Search code examples
tfsazure-devopstfs-2015azure-devops-rest-api

How to create a remote TFSGIT Repo programatically?


Is there any API I could use in order to create a new GIT Repo in the remote TFS Server?

Ideally something like

New-GitRepo -server myServer -team team1 -name myRepo

if there isn't a powershell api, i can do with a RESTful HTTP endpoint


Solution

  • The answer is in the docs:

    Use the REST API:

    POST https://{instance}/DefaultCollection/_apis/git/repositories/?api-version={version}
    Content-Type: application/json
    
    {
      "name": {string},
      "project": {
        "id": {guid}
      }
    }
    

    Though I don't know exactly from which TFS version this API became available. Given you tagged TFS2015 and the API compatibility has changed from RTM to update 3.