Expected Behavior
If I have the following terraform config ...
resource "github_repository" "example" {
name = "example"
auto_init = true
}
resource "github_branch_default" "default"{
repository = github_repository.example.name
branch = "main"
rename = true
}
... I expect the github_default_branch resource being created without issues.
Actual Behavior
The terraform plan succeeds without issues BUT on the terraform apply aka the creation of the github_default_branch resource an API call is made to rename the default branch from main to main. This API call fails with status code 422.
Doing an API call to rename main to main does not really make sense, fails and is an additional call which is not required.
A small condition only doing the rename-call if it makes sense would fix the issue aka if current_name != new_name.
See:
Terraform Version
Terraform v1.5.7
on linux_amd64
- provider registry.terraform.io/integrations/github v5.36.0
Affected Resource(s)
Terraform Configuration Files
No response
Steps to Reproduce
No response
Debug Output
No response
Panic Output

Code of Conduct
Expected Behavior
If I have the following terraform config ...
... I expect the
github_default_branchresource being created without issues.Actual Behavior
The
terraform plansucceeds without issues BUT on theterraform applyaka the creation of thegithub_default_branchresource an API call is made to rename the default branch frommaintomain. This API call fails with status code422.Doing an API call to rename
maintomaindoes not really make sense, fails and is an additional call which is not required.A small condition only doing the rename-call if it makes sense would fix the issue aka
if current_name != new_name.See:
Terraform Version
Terraform v1.5.7
on linux_amd64
Affected Resource(s)
Terraform Configuration Files
No response
Steps to Reproduce
No response
Debug Output
No response
Panic Output
Code of Conduct