[Azure DevOps] Cannot add files to project created repository

I want to commit a file (let’s say the README) on the default repository of a newly created project.
Below the code

resource "azuredevops_project" "example" {
  name               = "Example Project"
  visibility         = "private"
  version_control    = "Git"
  work_item_template = "Agile"
}

resource "azuredevops_git_repository" "example" {
  project_id = azuredevops_project.example.id
  name       = azuredevops_project.example.name
  initialization {
    init_type = "Clean"
  }
}

resource "azuredevops_git_repository_file" "example" {
  repository_id       = azuredevops_git_repository.example.id
  file                = "README.md"
  content             = "foo bar"
  branch              = "refs/heads/master"
  commit_message      = "First commit"
  overwrite_on_create = false
}

It gives me the following error:
Error creating repository in Azure DevOps: TF400948: A Git repository with the name Example Project already exists

I tried using the lifecycle argument with no luck and I also tried using a data source, but then the azuredevops_git_repository_file resource complain about missing branch.

It seems to me there is no way to create a branch from terraform, what am I missing??

1 Like

Same problem.
after import I receive error:
Error updating repository in Azure DevOps: TF401020: The Git ref with name refs/heads/main does not exist in the repository with name or identifier

so this repo can’t be usable by terraform.
btw. I see that organisation level policy seems don’t work to propagate default branch creation