I don\'t see an option to checkout or list remote/local branches in this module: https://gitpython.readthedocs.io/en/stable/
Basically, with GitPython, if you know how to do it within command line, but not within the API, just use repo.git.action("your command without leading 'git' and 'action'"), example: git log --reverse => repo.git.log('--reverse')
in this case https://stackoverflow.com/a/47872315/12550269
So I try this command:
repo = git.Repo()
repo.git.checkout('-b', local_branch, remote_branch)
this command can make a new local branch name local_branch
(if already haved, rasie error) and set up to track remote branch remote_branch
it works very well!