0

I've written this code to change the default branch from "master" to "release".

from github import Github
g = Github("github token", verify=False, base_url="url to repo")

repo = g.get_repo("repo name")
repo.default_branch = 'release'

I am getting the following error.

   repo.default_branch = 'release'
AttributeError: can't set attribute

I am the admin of that repository and I created the branch. I don't think this is an access issue. What am I doing incorrectly?

torek
  • 448,244
  • 59
  • 642
  • 775

1 Answers1

2

The default_branch attribute is a read-only attribute; if you want to change the default branch you need to use the edit method:

repo.edit(default_branch='release')
larsks
  • 277,717
  • 41
  • 399
  • 399