Checkout or list remote branches in GitPython

后端 未结 6 874
轮回少年
轮回少年 2020-12-18 21:29

I don\'t see an option to checkout or list remote/local branches in this module: https://gitpython.readthedocs.io/en/stable/

6条回答
  •  星月不相逢
    2020-12-18 22:08

    For those who want to just print the remote branches:

    # Execute from the repository root directory
    repo = git.Repo('.')
    remote_refs = repo.remote().refs
    
    for refs in remote_refs:
        print(refs.name)
    

提交回复
热议问题