Skip to content

Instantly share code, notes, and snippets.

@wehappyfew
wehappyfew / change_default_gh_branch.py
Last active September 15, 2020 14:16
Change the default branch of a GH repo. I use it with CodeDeploy in order to deploy different branch each time. Enjoy.
import json,requests,pprint
gh_url = "https://api.github.com"
username = 'wehappyfew'
# a token is needed for 2 Factor Auth, otherwise only Name/Pass
custom_token = 'blablablablablablabla' # a custom personal token from GitHub
repo_name = 'your_repo_name'
new_default_branch = 'something' # this is going to change every time
#encode to JSON