diff --git a/github/resource_github_repository.go b/github/resource_github_repository.go index 91cd737516..5e4d9948e5 100644 --- a/github/resource_github_repository.go +++ b/github/resource_github_repository.go @@ -170,8 +170,8 @@ func resourceGithubRepositoryCreate(d *schema.ResourceData, meta interface{}) er client := meta.(*Organization).client - if _, ok := d.GetOk("default_branch"); ok { - return fmt.Errorf("Cannot set the default branch on a new repository.") + if branchName, hasDefaultBranch := d.GetOk("default_branch"); hasDefaultBranch && (branchName != "master") { + return fmt.Errorf("Cannot set the default branch on a new repository to something other than 'master'.") } orgName := meta.(*Organization).name diff --git a/github/resource_github_repository_test.go b/github/resource_github_repository_test.go index 9b3682c152..fcd9ce7141 100644 --- a/github/resource_github_repository_test.go +++ b/github/resource_github_repository_test.go @@ -739,6 +739,7 @@ resource "github_repository" "foo" { allow_rebase_merge = false has_downloads = true auto_init = true + default_branch = "master" } `, randString, randString) }