If the branch exists:
repo.git.checkout('branchename')
If not:
repo.git.checkout('-b', 'branchename')
Basically, with GitPython, if you know how to do this on the command line, but not inside the API, just use repo.git.action("your command without leading 'git' and 'action'") , for example: git log --reverse => repo.git.log('--reverse')
source share