1

How can I create a new branch off the master and check out the branch?

The documentation at https://pygithub.readthedocs.io/en/latest/ does not show how to do this.

Thanks a lot!!

Kay
  • 1,235
  • 2
  • 13
  • 27

1 Answers1

1

I was able to do this with this code

g = Github("user", "pass")
repoName = "apiTest"
source_branch = 'master'
target_branch = 'newfeature'

repo = g.get_user().get_repo(repoName)
sb = repo.get_branch(source_branch)
repo.create_git_ref(ref='refs/heads/' + target_branch, sha=sb.commit.sha)
Kay
  • 1,235
  • 2
  • 13
  • 27