1. Registry
  2. Packages
  3. Github Provider
  4. API Docs
  5. BranchDefault
Viewing docs for GitHub v6.15.0
published on Friday, Aug 14, 2026 by Pulumi
github logo github logo
Viewing docs for GitHub v6.15.0
published on Friday, Aug 14, 2026 by Pulumi

    Configures the default branch for a GitHub repository.

    This resource is incompatible with the defaultBranch option of the github.Repository resource. Using both will result in plans always showing a diff.

    Example Usage

    import * as pulumi from "@pulumi/pulumi";
    import * as github from "@pulumi/github";
    
    // Basic usage 
    const example = new github.Repository("example", {
        name: "example",
        description: "My awesome codebase",
        autoInit: true,
    });
    const development = new github.Branch("development", {
        repository: example.name,
        branch: "development",
    });
    const _default = new github.BranchDefault("default", {
        repository: example.name,
        branch: development.branch,
    });
    
    import pulumi
    import pulumi_github as github
    
    # Basic usage 
    example = github.Repository("example",
        name="example",
        description="My awesome codebase",
        auto_init=True)
    development = github.Branch("development",
        repository=example.name,
        branch="development")
    default = github.BranchDefault("default",
        repository=example.name,
        branch=development.branch)
    
    package main
    
    import (
    	"github.com/pulumi/pulumi-github/sdk/v6/go/github"
    	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
    )
    
    func main() {
    	pulumi.Run(func(ctx *pulumi.Context) error {
    		// Basic usage
    		example, err := github.NewRepository(ctx, "example", &github.RepositoryArgs{
    			Name:        pulumi.String("example"),
    			Description: pulumi.String("My awesome codebase"),
    			AutoInit:    pulumi.Bool(true),
    		})
    		if err != nil {
    			return err
    		}
    		development, err := github.NewBranch(ctx, "development", &github.BranchArgs{
    			Repository: example.Name,
    			Branch:     pulumi.String("development"),
    		})
    		if err != nil {
    			return err
    		}
    		_, err = github.NewBranchDefault(ctx, "default", &github.BranchDefaultArgs{
    			Repository: example.Name,
    			Branch:     development.Branch,
    		})
    		if err != nil {
    			return err
    		}
    		return nil
    	})
    }
    
    using System.Collections.Generic;
    using System.Linq;
    using Pulumi;
    using Github = Pulumi.Github;
    
    return await Deployment.RunAsync(() => 
    {
        // Basic usage 
        var example = new Github.Repository("example", new()
        {
            Name = "example",
            Description = "My awesome codebase",
            AutoInit = true,
        });
    
        var development = new Github.Branch("development", new()
        {
            Repository = example.Name,
            BranchName = "development",
        });
    
        var @default = new Github.BranchDefault("default", new()
        {
            Repository = example.Name,
            Branch = development.BranchName,
        });
    
    });
    
    package generated_program;
    
    import com.pulumi.Context;
    import com.pulumi.Pulumi;
    import com.pulumi.core.Output;
    import com.pulumi.github.Repository;
    import com.pulumi.github.RepositoryArgs;
    import com.pulumi.github.Branch;
    import com.pulumi.github.BranchArgs;
    import com.pulumi.github.BranchDefault;
    import com.pulumi.github.BranchDefaultArgs;
    import java.util.ArrayList;
    import java.util.Arrays;
    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) {
            // Basic usage 
            var example = new Repository("example", RepositoryArgs.builder()
                .name("example")
                .description("My awesome codebase")
                .autoInit(true)
                .build());
    
            var development = new Branch("development", BranchArgs.builder()
                .repository(example.name())
                .branch("development")
                .build());
    
            var default_ = new BranchDefault("default", BranchDefaultArgs.builder()
                .repository(example.name())
                .branch(development.branch())
                .build());
    
        }
    }
    
    resources:
      # Basic usage
      example:
        type: github:Repository
        properties:
          name: example
          description: My awesome codebase
          autoInit: true
      development:
        type: github:Branch
        properties:
          repository: ${example.name}
          branch: development
      default:
        type: github:BranchDefault
        properties:
          repository: ${example.name}
          branch: ${development.branch}
    
    pulumi {
      required_providers {
        github = {
          source = "pulumi/github"
        }
      }
    }
    
    # Basic usage 
    resource "github_repository" "example" {
      name        = "example"
      description = "My awesome codebase"
      auto_init   = true
    }
    resource "github_branch" "development" {
      repository = github_repository.example.name
      branch     = "development"
    }
    resource "github_branchdefault" "default" {
      repository = github_repository.example.name
      branch     = github_branch.development.branch
    }
    
    import * as pulumi from "@pulumi/pulumi";
    import * as github from "@pulumi/github";
    
    // Renaming to a branch that doesn't exist
    const example = new github.Repository("example", {
        name: "example",
        description: "My awesome codebase",
        autoInit: true,
    });
    const _default = new github.BranchDefault("default", {
        repository: example.name,
        branch: "development",
        rename: true,
    });
    
    import pulumi
    import pulumi_github as github
    
    # Renaming to a branch that doesn't exist
    example = github.Repository("example",
        name="example",
        description="My awesome codebase",
        auto_init=True)
    default = github.BranchDefault("default",
        repository=example.name,
        branch="development",
        rename=True)
    
    package main
    
    import (
    	"github.com/pulumi/pulumi-github/sdk/v6/go/github"
    	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
    )
    
    func main() {
    	pulumi.Run(func(ctx *pulumi.Context) error {
    		// Renaming to a branch that doesn't exist
    		example, err := github.NewRepository(ctx, "example", &github.RepositoryArgs{
    			Name:        pulumi.String("example"),
    			Description: pulumi.String("My awesome codebase"),
    			AutoInit:    pulumi.Bool(true),
    		})
    		if err != nil {
    			return err
    		}
    		_, err = github.NewBranchDefault(ctx, "default", &github.BranchDefaultArgs{
    			Repository: example.Name,
    			Branch:     pulumi.String("development"),
    			Rename:     pulumi.Bool(true),
    		})
    		if err != nil {
    			return err
    		}
    		return nil
    	})
    }
    
    using System.Collections.Generic;
    using System.Linq;
    using Pulumi;
    using Github = Pulumi.Github;
    
    return await Deployment.RunAsync(() => 
    {
        // Renaming to a branch that doesn't exist
        var example = new Github.Repository("example", new()
        {
            Name = "example",
            Description = "My awesome codebase",
            AutoInit = true,
        });
    
        var @default = new Github.BranchDefault("default", new()
        {
            Repository = example.Name,
            Branch = "development",
            Rename = true,
        });
    
    });
    
    package generated_program;
    
    import com.pulumi.Context;
    import com.pulumi.Pulumi;
    import com.pulumi.core.Output;
    import com.pulumi.github.Repository;
    import com.pulumi.github.RepositoryArgs;
    import com.pulumi.github.BranchDefault;
    import com.pulumi.github.BranchDefaultArgs;
    import java.util.ArrayList;
    import java.util.Arrays;
    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) {
            // Renaming to a branch that doesn't exist
            var example = new Repository("example", RepositoryArgs.builder()
                .name("example")
                .description("My awesome codebase")
                .autoInit(true)
                .build());
    
            var default_ = new BranchDefault("default", BranchDefaultArgs.builder()
                .repository(example.name())
                .branch("development")
                .rename(true)
                .build());
    
        }
    }
    
    resources:
      # Renaming to a branch that doesn't exist
      example:
        type: github:Repository
        properties:
          name: example
          description: My awesome codebase
          autoInit: true
      default:
        type: github:BranchDefault
        properties:
          repository: ${example.name}
          branch: development
          rename: true
    
    pulumi {
      required_providers {
        github = {
          source = "pulumi/github"
        }
      }
    }
    
    # Renaming to a branch that doesn't exist
    resource "github_repository" "example" {
      name        = "example"
      description = "My awesome codebase"
      auto_init   = true
    }
    resource "github_branchdefault" "default" {
      repository = github_repository.example.name
      branch     = "development"
      rename     = true
    }
    

    Create BranchDefault Resource

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

    Constructor syntax

    new BranchDefault(name: string, args: BranchDefaultArgs, opts?: CustomResourceOptions);
    @overload
    def BranchDefault(resource_name: str,
                      args: BranchDefaultArgs,
                      opts: Optional[ResourceOptions] = None)
    
    @overload
    def BranchDefault(resource_name: str,
                      opts: Optional[ResourceOptions] = None,
                      branch: Optional[str] = None,
                      repository: Optional[str] = None,
                      etag: Optional[str] = None,
                      rename: Optional[bool] = None,
                      wait_for_rename: Optional[bool] = None)
    func NewBranchDefault(ctx *Context, name string, args BranchDefaultArgs, opts ...ResourceOption) (*BranchDefault, error)
    public BranchDefault(string name, BranchDefaultArgs args, CustomResourceOptions? opts = null)
    public BranchDefault(String name, BranchDefaultArgs args)
    public BranchDefault(String name, BranchDefaultArgs args, CustomResourceOptions options)
    
    type: github:BranchDefault
    properties: # The arguments to resource properties.
    options: # Bag of options to control resource's behavior.
    
    
    resource "github_branch_default" "name" {
        # resource properties
    }

    Parameters

    name string
    The unique name of the resource.
    args BranchDefaultArgs
    The arguments to resource properties.
    opts CustomResourceOptions
    Bag of options to control resource's behavior.
    resource_name str
    The unique name of the resource.
    args BranchDefaultArgs
    The arguments to resource properties.
    opts ResourceOptions
    Bag of options to control resource's behavior.
    ctx Context
    Context object for the current deployment.
    name string
    The unique name of the resource.
    args BranchDefaultArgs
    The arguments to resource properties.
    opts ResourceOption
    Bag of options to control resource's behavior.
    name string
    The unique name of the resource.
    args BranchDefaultArgs
    The arguments to resource properties.
    opts CustomResourceOptions
    Bag of options to control resource's behavior.
    name String
    The unique name of the resource.
    args BranchDefaultArgs
    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 branchDefaultResource = new Github.BranchDefault("branchDefaultResource", new()
    {
        Branch = "string",
        Repository = "string",
        Etag = "string",
        Rename = false,
        WaitForRename = false,
    });
    
    example, err := github.NewBranchDefault(ctx, "branchDefaultResource", &github.BranchDefaultArgs{
    	Branch:        pulumi.String("string"),
    	Repository:    pulumi.String("string"),
    	Etag:          pulumi.String("string"),
    	Rename:        pulumi.Bool(false),
    	WaitForRename: pulumi.Bool(false),
    })
    
    resource "github_branch_default" "branchDefaultResource" {
      lifecycle {
        create_before_destroy = true
      }
      branch          = "string"
      repository      = "string"
      etag            = "string"
      rename          = false
      wait_for_rename = false
    }
    
    var branchDefaultResource = new BranchDefault("branchDefaultResource", BranchDefaultArgs.builder()
        .branch("string")
        .repository("string")
        .etag("string")
        .rename(false)
        .waitForRename(false)
        .build());
    
    branch_default_resource = github.BranchDefault("branchDefaultResource",
        branch="string",
        repository="string",
        etag="string",
        rename=False,
        wait_for_rename=False)
    
    const branchDefaultResource = new github.BranchDefault("branchDefaultResource", {
        branch: "string",
        repository: "string",
        etag: "string",
        rename: false,
        waitForRename: false,
    });
    
    type: github:BranchDefault
    properties:
        branch: string
        etag: string
        rename: false
        repository: string
        waitForRename: false
    

    BranchDefault 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 BranchDefault resource accepts the following input properties:

    Branch string
    The name of the branch to set as the default (e.g. 'main').
    Repository string
    The name of the GitHub repository.
    Etag string
    The ETag header for the repository API response.
    Rename bool
    If true rename the existing branch when the branch input is changed. Defaults to 'false'.
    WaitForRename bool
    If true, poll until GitHub propagates the renamed default branch before proceeding. Only has effect when rename is also true. Defaults to 'false'.
    Branch string
    The name of the branch to set as the default (e.g. 'main').
    Repository string
    The name of the GitHub repository.
    Etag string
    The ETag header for the repository API response.
    Rename bool
    If true rename the existing branch when the branch input is changed. Defaults to 'false'.
    WaitForRename bool
    If true, poll until GitHub propagates the renamed default branch before proceeding. Only has effect when rename is also true. Defaults to 'false'.
    branch string
    The name of the branch to set as the default (e.g. 'main').
    repository string
    The name of the GitHub repository.
    etag string
    The ETag header for the repository API response.
    rename bool
    If true rename the existing branch when the branch input is changed. Defaults to 'false'.
    wait_for_rename bool
    If true, poll until GitHub propagates the renamed default branch before proceeding. Only has effect when rename is also true. Defaults to 'false'.
    branch String
    The name of the branch to set as the default (e.g. 'main').
    repository String
    The name of the GitHub repository.
    etag String
    The ETag header for the repository API response.
    rename Boolean
    If true rename the existing branch when the branch input is changed. Defaults to 'false'.
    waitForRename Boolean
    If true, poll until GitHub propagates the renamed default branch before proceeding. Only has effect when rename is also true. Defaults to 'false'.
    branch string
    The name of the branch to set as the default (e.g. 'main').
    repository string
    The name of the GitHub repository.
    etag string
    The ETag header for the repository API response.
    rename boolean
    If true rename the existing branch when the branch input is changed. Defaults to 'false'.
    waitForRename boolean
    If true, poll until GitHub propagates the renamed default branch before proceeding. Only has effect when rename is also true. Defaults to 'false'.
    branch str
    The name of the branch to set as the default (e.g. 'main').
    repository str
    The name of the GitHub repository.
    etag str
    The ETag header for the repository API response.
    rename bool
    If true rename the existing branch when the branch input is changed. Defaults to 'false'.
    wait_for_rename bool
    If true, poll until GitHub propagates the renamed default branch before proceeding. Only has effect when rename is also true. Defaults to 'false'.
    branch String
    The name of the branch to set as the default (e.g. 'main').
    repository String
    The name of the GitHub repository.
    etag String
    The ETag header for the repository API response.
    rename Boolean
    If true rename the existing branch when the branch input is changed. Defaults to 'false'.
    waitForRename Boolean
    If true, poll until GitHub propagates the renamed default branch before proceeding. Only has effect when rename is also true. Defaults to 'false'.

    Outputs

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

    Id string
    The provider-assigned unique ID for this managed resource.
    RepositoryId int
    The ID of the GitHub repository.
    Id string
    The provider-assigned unique ID for this managed resource.
    RepositoryId int
    The ID of the GitHub repository.
    id string
    The provider-assigned unique ID for this managed resource.
    repository_id number
    The ID of the GitHub repository.
    id String
    The provider-assigned unique ID for this managed resource.
    repositoryId Integer
    The ID of the GitHub repository.
    id string
    The provider-assigned unique ID for this managed resource.
    repositoryId number
    The ID of the GitHub repository.
    id str
    The provider-assigned unique ID for this managed resource.
    repository_id int
    The ID of the GitHub repository.
    id String
    The provider-assigned unique ID for this managed resource.
    repositoryId Number
    The ID of the GitHub repository.

    Look up Existing BranchDefault Resource

    Get an existing BranchDefault 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?: BranchDefaultState, opts?: CustomResourceOptions): BranchDefault
    @staticmethod
    def get(resource_name: str,
            id: str,
            opts: Optional[ResourceOptions] = None,
            branch: Optional[str] = None,
            etag: Optional[str] = None,
            rename: Optional[bool] = None,
            repository: Optional[str] = None,
            repository_id: Optional[int] = None,
            wait_for_rename: Optional[bool] = None) -> BranchDefault
    func GetBranchDefault(ctx *Context, name string, id IDInput, state *BranchDefaultState, opts ...ResourceOption) (*BranchDefault, error)
    public static BranchDefault Get(string name, Input<string> id, BranchDefaultState? state, CustomResourceOptions? opts = null)
    public static BranchDefault get(String name, Output<String> id, BranchDefaultState state, CustomResourceOptions options)
    resources:  _:    type: github:BranchDefault    get:      id: ${id}
    import {
      to = github_branch_default.example
      id = "${id}"
    }
    
    name
    The unique name of the resulting resource.
    id
    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
    The unique name of the resulting resource.
    id
    The unique provider ID of the resource to lookup.
    name
    The unique name of the resulting resource.
    id
    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
    The unique name of the resulting resource.
    id
    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
    The unique name of the resulting resource.
    id
    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:
    Branch string
    The name of the branch to set as the default (e.g. 'main').
    Etag string
    The ETag header for the repository API response.
    Rename bool
    If true rename the existing branch when the branch input is changed. Defaults to 'false'.
    Repository string
    The name of the GitHub repository.
    RepositoryId int
    The ID of the GitHub repository.
    WaitForRename bool
    If true, poll until GitHub propagates the renamed default branch before proceeding. Only has effect when rename is also true. Defaults to 'false'.
    Branch string
    The name of the branch to set as the default (e.g. 'main').
    Etag string
    The ETag header for the repository API response.
    Rename bool
    If true rename the existing branch when the branch input is changed. Defaults to 'false'.
    Repository string
    The name of the GitHub repository.
    RepositoryId int
    The ID of the GitHub repository.
    WaitForRename bool
    If true, poll until GitHub propagates the renamed default branch before proceeding. Only has effect when rename is also true. Defaults to 'false'.
    branch string
    The name of the branch to set as the default (e.g. 'main').
    etag string
    The ETag header for the repository API response.
    rename bool
    If true rename the existing branch when the branch input is changed. Defaults to 'false'.
    repository string
    The name of the GitHub repository.
    repository_id number
    The ID of the GitHub repository.
    wait_for_rename bool
    If true, poll until GitHub propagates the renamed default branch before proceeding. Only has effect when rename is also true. Defaults to 'false'.
    branch String
    The name of the branch to set as the default (e.g. 'main').
    etag String
    The ETag header for the repository API response.
    rename Boolean
    If true rename the existing branch when the branch input is changed. Defaults to 'false'.
    repository String
    The name of the GitHub repository.
    repositoryId Integer
    The ID of the GitHub repository.
    waitForRename Boolean
    If true, poll until GitHub propagates the renamed default branch before proceeding. Only has effect when rename is also true. Defaults to 'false'.
    branch string
    The name of the branch to set as the default (e.g. 'main').
    etag string
    The ETag header for the repository API response.
    rename boolean
    If true rename the existing branch when the branch input is changed. Defaults to 'false'.
    repository string
    The name of the GitHub repository.
    repositoryId number
    The ID of the GitHub repository.
    waitForRename boolean
    If true, poll until GitHub propagates the renamed default branch before proceeding. Only has effect when rename is also true. Defaults to 'false'.
    branch str
    The name of the branch to set as the default (e.g. 'main').
    etag str
    The ETag header for the repository API response.
    rename bool
    If true rename the existing branch when the branch input is changed. Defaults to 'false'.
    repository str
    The name of the GitHub repository.
    repository_id int
    The ID of the GitHub repository.
    wait_for_rename bool
    If true, poll until GitHub propagates the renamed default branch before proceeding. Only has effect when rename is also true. Defaults to 'false'.
    branch String
    The name of the branch to set as the default (e.g. 'main').
    etag String
    The ETag header for the repository API response.
    rename Boolean
    If true rename the existing branch when the branch input is changed. Defaults to 'false'.
    repository String
    The name of the GitHub repository.
    repositoryId Number
    The ID of the GitHub repository.
    waitForRename Boolean
    If true, poll until GitHub propagates the renamed default branch before proceeding. Only has effect when rename is also true. Defaults to 'false'.

    Import

    The pulumi import command can be used, for example:

    $ pulumi import github:index/branchDefault:BranchDefault branch_default my-repo
    

    To learn more about importing existing cloud resources, see Importing resources.

    Package Details

    Repository
    GitHub pulumi/pulumi-github
    License
    Apache-2.0
    Notes
    This Pulumi package is based on the github Terraform Provider.
    github logo github logo
    Viewing docs for GitHub v6.15.0
    published on Friday, Aug 14, 2026 by Pulumi

      Try Pulumi Cloud free.
      Your team will thank you.

      Start free trial