我编写了这段代码来将默认分支从“master”更改为“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'
我收到以下错误。
repo.default_branch = 'release'
AttributeError: can't set attribute
我是该存储库的管理员,我创建了该分支。我不认为这是一个访问问题。我做错了什么?
最佳答案
default_branch
属性是只读属性;如果您想更改默认分支,您需要使用 edit
方法:
repo.edit(default_branch='release')
关于python - PyGithub - 尝试更改默认分支时无法设置属性错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/72813080/