1. Packages
  2. Azure DevOps Provider
  3. API Docs
  4. GitRepositoryBranch
Azure DevOps v3.8.0 published on Monday, Mar 17, 2025 by Pulumi

azuredevops.GitRepositoryBranch

Explore with Pulumi AI

Manages a Git Repository Branch.

Example Usage

import * as pulumi from "@pulumi/pulumi";
import * as azuredevops from "@pulumi/azuredevops";

const example = new azuredevops.Project("example", {
    name: "Example Project",
    visibility: "private",
    versionControl: "Git",
    workItemTemplate: "Agile",
});
const exampleGit = new azuredevops.Git("example", {
    projectId: example.id,
    name: "Example Git Repository",
    initialization: {
        initType: "Clean",
    },
});
const exampleGitRepositoryBranch = new azuredevops.GitRepositoryBranch("example", {
    repositoryId: exampleGit.id,
    name: "example-branch-name",
    refBranch: exampleGit.defaultBranch,
});
const exampleFromCommitId = new azuredevops.GitRepositoryBranch("example_from_commit_id", {
    repositoryId: exampleGit.id,
    name: "example-from-commit-id",
    refCommitId: exampleGitRepositoryBranch.lastCommitId,
});
Copy
import pulumi
import pulumi_azuredevops as azuredevops

example = azuredevops.Project("example",
    name="Example Project",
    visibility="private",
    version_control="Git",
    work_item_template="Agile")
example_git = azuredevops.Git("example",
    project_id=example.id,
    name="Example Git Repository",
    initialization={
        "init_type": "Clean",
    })
example_git_repository_branch = azuredevops.GitRepositoryBranch("example",
    repository_id=example_git.id,
    name="example-branch-name",
    ref_branch=example_git.default_branch)
example_from_commit_id = azuredevops.GitRepositoryBranch("example_from_commit_id",
    repository_id=example_git.id,
    name="example-from-commit-id",
    ref_commit_id=example_git_repository_branch.last_commit_id)
Copy
package main

import (
	"github.com/pulumi/pulumi-azuredevops/sdk/v3/go/azuredevops"
	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)

func main() {
	pulumi.Run(func(ctx *pulumi.Context) error {
		example, err := azuredevops.NewProject(ctx, "example", &azuredevops.ProjectArgs{
			Name:             pulumi.String("Example Project"),
			Visibility:       pulumi.String("private"),
			VersionControl:   pulumi.String("Git"),
			WorkItemTemplate: pulumi.String("Agile"),
		})
		if err != nil {
			return err
		}
		exampleGit, err := azuredevops.NewGit(ctx, "example", &azuredevops.GitArgs{
			ProjectId: example.ID(),
			Name:      pulumi.String("Example Git Repository"),
			Initialization: &azuredevops.GitInitializationArgs{
				InitType: pulumi.String("Clean"),
			},
		})
		if err != nil {
			return err
		}
		exampleGitRepositoryBranch, err := azuredevops.NewGitRepositoryBranch(ctx, "example", &azuredevops.GitRepositoryBranchArgs{
			RepositoryId: exampleGit.ID(),
			Name:         pulumi.String("example-branch-name"),
			RefBranch:    exampleGit.DefaultBranch,
		})
		if err != nil {
			return err
		}
		_, err = azuredevops.NewGitRepositoryBranch(ctx, "example_from_commit_id", &azuredevops.GitRepositoryBranchArgs{
			RepositoryId: exampleGit.ID(),
			Name:         pulumi.String("example-from-commit-id"),
			RefCommitId:  exampleGitRepositoryBranch.LastCommitId,
		})
		if err != nil {
			return err
		}
		return nil
	})
}
Copy
using System.Collections.Generic;
using System.Linq;
using Pulumi;
using AzureDevOps = Pulumi.AzureDevOps;

return await Deployment.RunAsync(() => 
{
    var example = new AzureDevOps.Project("example", new()
    {
        Name = "Example Project",
        Visibility = "private",
        VersionControl = "Git",
        WorkItemTemplate = "Agile",
    });

    var exampleGit = new AzureDevOps.Git("example", new()
    {
        ProjectId = example.Id,
        Name = "Example Git Repository",
        Initialization = new AzureDevOps.Inputs.GitInitializationArgs
        {
            InitType = "Clean",
        },
    });

    var exampleGitRepositoryBranch = new AzureDevOps.GitRepositoryBranch("example", new()
    {
        RepositoryId = exampleGit.Id,
        Name = "example-branch-name",
        RefBranch = exampleGit.DefaultBranch,
    });

    var exampleFromCommitId = new AzureDevOps.GitRepositoryBranch("example_from_commit_id", new()
    {
        RepositoryId = exampleGit.Id,
        Name = "example-from-commit-id",
        RefCommitId = exampleGitRepositoryBranch.LastCommitId,
    });

});
Copy
package generated_program;

import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.azuredevops.Project;
import com.pulumi.azuredevops.ProjectArgs;
import com.pulumi.azuredevops.Git;
import com.pulumi.azuredevops.GitArgs;
import com.pulumi.azuredevops.inputs.GitInitializationArgs;
import com.pulumi.azuredevops.GitRepositoryBranch;
import com.pulumi.azuredevops.GitRepositoryBranchArgs;
import java.util.List;
import java.util.ArrayList;
import java.util.Map;
import java.io.File;
import java.nio.file.Files;
import java.nio.file.Paths;

public class App {
    public static void main(String[] args) {
        Pulumi.run(App::stack);
    }

    public static void stack(Context ctx) {
        var example = new Project("example", ProjectArgs.builder()
            .name("Example Project")
            .visibility("private")
            .versionControl("Git")
            .workItemTemplate("Agile")
            .build());

        var exampleGit = new Git("exampleGit", GitArgs.builder()
            .projectId(example.id())
            .name("Example Git Repository")
            .initialization(GitInitializationArgs.builder()
                .initType("Clean")
                .build())
            .build());

        var exampleGitRepositoryBranch = new GitRepositoryBranch("exampleGitRepositoryBranch", GitRepositoryBranchArgs.builder()
            .repositoryId(exampleGit.id())
            .name("example-branch-name")
            .refBranch(exampleGit.defaultBranch())
            .build());

        var exampleFromCommitId = new GitRepositoryBranch("exampleFromCommitId", GitRepositoryBranchArgs.builder()
            .repositoryId(exampleGit.id())
            .name("example-from-commit-id")
            .refCommitId(exampleGitRepositoryBranch.lastCommitId())
            .build());

    }
}
Copy
resources:
  example:
    type: azuredevops:Project
    properties:
      name: Example Project
      visibility: private
      versionControl: Git
      workItemTemplate: Agile
  exampleGit:
    type: azuredevops:Git
    name: example
    properties:
      projectId: ${example.id}
      name: Example Git Repository
      initialization:
        initType: Clean
  exampleGitRepositoryBranch:
    type: azuredevops:GitRepositoryBranch
    name: example
    properties:
      repositoryId: ${exampleGit.id}
      name: example-branch-name
      refBranch: ${exampleGit.defaultBranch}
  exampleFromCommitId:
    type: azuredevops:GitRepositoryBranch
    name: example_from_commit_id
    properties:
      repositoryId: ${exampleGit.id}
      name: example-from-commit-id
      refCommitId: ${exampleGitRepositoryBranch.lastCommitId}
Copy

Create GitRepositoryBranch Resource

Resources are created with functions called constructors. To learn more about declaring and configuring resources, see Resources.

Constructor syntax

new GitRepositoryBranch(name: string, args: GitRepositoryBranchArgs, opts?: CustomResourceOptions);
@overload
def GitRepositoryBranch(resource_name: str,
                        args: GitRepositoryBranchArgs,
                        opts: Optional[ResourceOptions] = None)

@overload
def GitRepositoryBranch(resource_name: str,
                        opts: Optional[ResourceOptions] = None,
                        repository_id: Optional[str] = None,
                        name: Optional[str] = None,
                        ref_branch: Optional[str] = None,
                        ref_commit_id: Optional[str] = None,
                        ref_tag: Optional[str] = None)
func NewGitRepositoryBranch(ctx *Context, name string, args GitRepositoryBranchArgs, opts ...ResourceOption) (*GitRepositoryBranch, error)
public GitRepositoryBranch(string name, GitRepositoryBranchArgs args, CustomResourceOptions? opts = null)
public GitRepositoryBranch(String name, GitRepositoryBranchArgs args)
public GitRepositoryBranch(String name, GitRepositoryBranchArgs args, CustomResourceOptions options)
type: azuredevops:GitRepositoryBranch
properties: # The arguments to resource properties.
options: # Bag of options to control resource's behavior.

Parameters

name This property is required. string
The unique name of the resource.
args This property is required. GitRepositoryBranchArgs
The arguments to resource properties.
opts CustomResourceOptions
Bag of options to control resource's behavior.
resource_name This property is required. str
The unique name of the resource.
args This property is required. GitRepositoryBranchArgs
The arguments to resource properties.
opts ResourceOptions
Bag of options to control resource's behavior.
ctx Context
Context object for the current deployment.
name This property is required. string
The unique name of the resource.
args This property is required. GitRepositoryBranchArgs
The arguments to resource properties.
opts ResourceOption
Bag of options to control resource's behavior.
name This property is required. string
The unique name of the resource.
args This property is required. GitRepositoryBranchArgs
The arguments to resource properties.
opts CustomResourceOptions
Bag of options to control resource's behavior.
name This property is required. String
The unique name of the resource.
args This property is required. GitRepositoryBranchArgs
The arguments to resource properties.
options CustomResourceOptions
Bag of options to control resource's behavior.

Constructor example

The following reference example uses placeholder values for all input properties.

var gitRepositoryBranchResource = new AzureDevOps.GitRepositoryBranch("gitRepositoryBranchResource", new()
{
    RepositoryId = "string",
    Name = "string",
    RefBranch = "string",
    RefCommitId = "string",
    RefTag = "string",
});
Copy
example, err := azuredevops.NewGitRepositoryBranch(ctx, "gitRepositoryBranchResource", &azuredevops.GitRepositoryBranchArgs{
	RepositoryId: pulumi.String("string"),
	Name:         pulumi.String("string"),
	RefBranch:    pulumi.String("string"),
	RefCommitId:  pulumi.String("string"),
	RefTag:       pulumi.String("string"),
})
Copy
var gitRepositoryBranchResource = new GitRepositoryBranch("gitRepositoryBranchResource", GitRepositoryBranchArgs.builder()
    .repositoryId("string")
    .name("string")
    .refBranch("string")
    .refCommitId("string")
    .refTag("string")
    .build());
Copy
git_repository_branch_resource = azuredevops.GitRepositoryBranch("gitRepositoryBranchResource",
    repository_id="string",
    name="string",
    ref_branch="string",
    ref_commit_id="string",
    ref_tag="string")
Copy
const gitRepositoryBranchResource = new azuredevops.GitRepositoryBranch("gitRepositoryBranchResource", {
    repositoryId: "string",
    name: "string",
    refBranch: "string",
    refCommitId: "string",
    refTag: "string",
});
Copy
type: azuredevops:GitRepositoryBranch
properties:
    name: string
    refBranch: string
    refCommitId: string
    refTag: string
    repositoryId: string
Copy

GitRepositoryBranch Resource Properties

To learn more about resource properties and how to use them, see Inputs and Outputs in the Architecture and Concepts docs.

Inputs

In Python, inputs that are objects can be passed either as argument classes or as dictionary literals.

The GitRepositoryBranch resource accepts the following input properties:

RepositoryId
This property is required.
Changes to this property will trigger replacement.
string
The ID of the repository the branch is created against.
Name Changes to this property will trigger replacement. string
The name of the branch in short format not prefixed with refs/heads/.
RefBranch Changes to this property will trigger replacement. string
The reference to the source branch to create the branch from, in <name> or refs/heads/<name> format. Conflict with ref_tag, ref_commit_id.
RefCommitId Changes to this property will trigger replacement. string
The commit object ID to create the branch from. Conflict with ref_branch, ref_tag.
RefTag Changes to this property will trigger replacement. string
The reference to the tag to create the branch from, in <name> or refs/tags/<name> format. Conflict with ref_branch, ref_commit_id.
RepositoryId
This property is required.
Changes to this property will trigger replacement.
string
The ID of the repository the branch is created against.
Name Changes to this property will trigger replacement. string
The name of the branch in short format not prefixed with refs/heads/.
RefBranch Changes to this property will trigger replacement. string
The reference to the source branch to create the branch from, in <name> or refs/heads/<name> format. Conflict with ref_tag, ref_commit_id.
RefCommitId Changes to this property will trigger replacement. string
The commit object ID to create the branch from. Conflict with ref_branch, ref_tag.
RefTag Changes to this property will trigger replacement. string
The reference to the tag to create the branch from, in <name> or refs/tags/<name> format. Conflict with ref_branch, ref_commit_id.
repositoryId
This property is required.
Changes to this property will trigger replacement.
String
The ID of the repository the branch is created against.
name Changes to this property will trigger replacement. String
The name of the branch in short format not prefixed with refs/heads/.
refBranch Changes to this property will trigger replacement. String
The reference to the source branch to create the branch from, in <name> or refs/heads/<name> format. Conflict with ref_tag, ref_commit_id.
refCommitId Changes to this property will trigger replacement. String
The commit object ID to create the branch from. Conflict with ref_branch, ref_tag.
refTag Changes to this property will trigger replacement. String
The reference to the tag to create the branch from, in <name> or refs/tags/<name> format. Conflict with ref_branch, ref_commit_id.
repositoryId
This property is required.
Changes to this property will trigger replacement.
string
The ID of the repository the branch is created against.
name Changes to this property will trigger replacement. string
The name of the branch in short format not prefixed with refs/heads/.
refBranch Changes to this property will trigger replacement. string
The reference to the source branch to create the branch from, in <name> or refs/heads/<name> format. Conflict with ref_tag, ref_commit_id.
refCommitId Changes to this property will trigger replacement. string
The commit object ID to create the branch from. Conflict with ref_branch, ref_tag.
refTag Changes to this property will trigger replacement. string
The reference to the tag to create the branch from, in <name> or refs/tags/<name> format. Conflict with ref_branch, ref_commit_id.
repository_id
This property is required.
Changes to this property will trigger replacement.
str
The ID of the repository the branch is created against.
name Changes to this property will trigger replacement. str
The name of the branch in short format not prefixed with refs/heads/.
ref_branch Changes to this property will trigger replacement. str
The reference to the source branch to create the branch from, in <name> or refs/heads/<name> format. Conflict with ref_tag, ref_commit_id.
ref_commit_id Changes to this property will trigger replacement. str
The commit object ID to create the branch from. Conflict with ref_branch, ref_tag.
ref_tag Changes to this property will trigger replacement. str
The reference to the tag to create the branch from, in <name> or refs/tags/<name> format. Conflict with ref_branch, ref_commit_id.
repositoryId
This property is required.
Changes to this property will trigger replacement.
String
The ID of the repository the branch is created against.
name Changes to this property will trigger replacement. String
The name of the branch in short format not prefixed with refs/heads/.
refBranch Changes to this property will trigger replacement. String
The reference to the source branch to create the branch from, in <name> or refs/heads/<name> format. Conflict with ref_tag, ref_commit_id.
refCommitId Changes to this property will trigger replacement. String
The commit object ID to create the branch from. Conflict with ref_branch, ref_tag.
refTag Changes to this property will trigger replacement. String
The reference to the tag to create the branch from, in <name> or refs/tags/<name> format. Conflict with ref_branch, ref_commit_id.

Outputs

All input properties are implicitly available as output properties. Additionally, the GitRepositoryBranch resource produces the following output properties:

Id string
The provider-assigned unique ID for this managed resource.
LastCommitId string
The commit object ID of last commit on the branch.
Id string
The provider-assigned unique ID for this managed resource.
LastCommitId string
The commit object ID of last commit on the branch.
id String
The provider-assigned unique ID for this managed resource.
lastCommitId String
The commit object ID of last commit on the branch.
id string
The provider-assigned unique ID for this managed resource.
lastCommitId string
The commit object ID of last commit on the branch.
id str
The provider-assigned unique ID for this managed resource.
last_commit_id str
The commit object ID of last commit on the branch.
id String
The provider-assigned unique ID for this managed resource.
lastCommitId String
The commit object ID of last commit on the branch.

Look up Existing GitRepositoryBranch Resource

Get an existing GitRepositoryBranch resource’s state with the given name, ID, and optional extra properties used to qualify the lookup.

public static get(name: string, id: Input<ID>, state?: GitRepositoryBranchState, opts?: CustomResourceOptions): GitRepositoryBranch
@staticmethod
def get(resource_name: str,
        id: str,
        opts: Optional[ResourceOptions] = None,
        last_commit_id: Optional[str] = None,
        name: Optional[str] = None,
        ref_branch: Optional[str] = None,
        ref_commit_id: Optional[str] = None,
        ref_tag: Optional[str] = None,
        repository_id: Optional[str] = None) -> GitRepositoryBranch
func GetGitRepositoryBranch(ctx *Context, name string, id IDInput, state *GitRepositoryBranchState, opts ...ResourceOption) (*GitRepositoryBranch, error)
public static GitRepositoryBranch Get(string name, Input<string> id, GitRepositoryBranchState? state, CustomResourceOptions? opts = null)
public static GitRepositoryBranch get(String name, Output<String> id, GitRepositoryBranchState state, CustomResourceOptions options)
resources:  _:    type: azuredevops:GitRepositoryBranch    get:      id: ${id}
name This property is required.
The unique name of the resulting resource.
id This property is required.
The unique provider ID of the resource to lookup.
state
Any extra arguments used during the lookup.
opts
A bag of options that control this resource's behavior.
resource_name This property is required.
The unique name of the resulting resource.
id This property is required.
The unique provider ID of the resource to lookup.
name This property is required.
The unique name of the resulting resource.
id This property is required.
The unique provider ID of the resource to lookup.
state
Any extra arguments used during the lookup.
opts
A bag of options that control this resource's behavior.
name This property is required.
The unique name of the resulting resource.
id This property is required.
The unique provider ID of the resource to lookup.
state
Any extra arguments used during the lookup.
opts
A bag of options that control this resource's behavior.
name This property is required.
The unique name of the resulting resource.
id This property is required.
The unique provider ID of the resource to lookup.
state
Any extra arguments used during the lookup.
opts
A bag of options that control this resource's behavior.
The following state arguments are supported:
LastCommitId string
The commit object ID of last commit on the branch.
Name Changes to this property will trigger replacement. string
The name of the branch in short format not prefixed with refs/heads/.
RefBranch Changes to this property will trigger replacement. string
The reference to the source branch to create the branch from, in <name> or refs/heads/<name> format. Conflict with ref_tag, ref_commit_id.
RefCommitId Changes to this property will trigger replacement. string
The commit object ID to create the branch from. Conflict with ref_branch, ref_tag.
RefTag Changes to this property will trigger replacement. string
The reference to the tag to create the branch from, in <name> or refs/tags/<name> format. Conflict with ref_branch, ref_commit_id.
RepositoryId Changes to this property will trigger replacement. string
The ID of the repository the branch is created against.
LastCommitId string
The commit object ID of last commit on the branch.
Name Changes to this property will trigger replacement. string
The name of the branch in short format not prefixed with refs/heads/.
RefBranch Changes to this property will trigger replacement. string
The reference to the source branch to create the branch from, in <name> or refs/heads/<name> format. Conflict with ref_tag, ref_commit_id.
RefCommitId Changes to this property will trigger replacement. string
The commit object ID to create the branch from. Conflict with ref_branch, ref_tag.
RefTag Changes to this property will trigger replacement. string
The reference to the tag to create the branch from, in <name> or refs/tags/<name> format. Conflict with ref_branch, ref_commit_id.
RepositoryId Changes to this property will trigger replacement. string
The ID of the repository the branch is created against.
lastCommitId String
The commit object ID of last commit on the branch.
name Changes to this property will trigger replacement. String
The name of the branch in short format not prefixed with refs/heads/.
refBranch Changes to this property will trigger replacement. String
The reference to the source branch to create the branch from, in <name> or refs/heads/<name> format. Conflict with ref_tag, ref_commit_id.
refCommitId Changes to this property will trigger replacement. String
The commit object ID to create the branch from. Conflict with ref_branch, ref_tag.
refTag Changes to this property will trigger replacement. String
The reference to the tag to create the branch from, in <name> or refs/tags/<name> format. Conflict with ref_branch, ref_commit_id.
repositoryId Changes to this property will trigger replacement. String
The ID of the repository the branch is created against.
lastCommitId string
The commit object ID of last commit on the branch.
name Changes to this property will trigger replacement. string
The name of the branch in short format not prefixed with refs/heads/.
refBranch Changes to this property will trigger replacement. string
The reference to the source branch to create the branch from, in <name> or refs/heads/<name> format. Conflict with ref_tag, ref_commit_id.
refCommitId Changes to this property will trigger replacement. string
The commit object ID to create the branch from. Conflict with ref_branch, ref_tag.
refTag Changes to this property will trigger replacement. string
The reference to the tag to create the branch from, in <name> or refs/tags/<name> format. Conflict with ref_branch, ref_commit_id.
repositoryId Changes to this property will trigger replacement. string
The ID of the repository the branch is created against.
last_commit_id str
The commit object ID of last commit on the branch.
name Changes to this property will trigger replacement. str
The name of the branch in short format not prefixed with refs/heads/.
ref_branch Changes to this property will trigger replacement. str
The reference to the source branch to create the branch from, in <name> or refs/heads/<name> format. Conflict with ref_tag, ref_commit_id.
ref_commit_id Changes to this property will trigger replacement. str
The commit object ID to create the branch from. Conflict with ref_branch, ref_tag.
ref_tag Changes to this property will trigger replacement. str
The reference to the tag to create the branch from, in <name> or refs/tags/<name> format. Conflict with ref_branch, ref_commit_id.
repository_id Changes to this property will trigger replacement. str
The ID of the repository the branch is created against.
lastCommitId String
The commit object ID of last commit on the branch.
name Changes to this property will trigger replacement. String
The name of the branch in short format not prefixed with refs/heads/.
refBranch Changes to this property will trigger replacement. String
The reference to the source branch to create the branch from, in <name> or refs/heads/<name> format. Conflict with ref_tag, ref_commit_id.
refCommitId Changes to this property will trigger replacement. String
The commit object ID to create the branch from. Conflict with ref_branch, ref_tag.
refTag Changes to this property will trigger replacement. String
The reference to the tag to create the branch from, in <name> or refs/tags/<name> format. Conflict with ref_branch, ref_commit_id.
repositoryId Changes to this property will trigger replacement. String
The ID of the repository the branch is created against.

Package Details

Repository
Azure DevOps pulumi/pulumi-azuredevops
License
Apache-2.0
Notes
This Pulumi package is based on the azuredevops Terraform Provider.