How to clone from specific branch from Git using Gitpython

前端 未结 2 1967
温柔的废话
温柔的废话 2021-01-05 19:06

I tried to clone a repository from git using GitPython in python function. I used GitPython library for cloning from git in my python function and my code snippet as follows

相关标签:
2条回答
  • 2021-01-05 19:21

    just pass the branch name parameter, e.g. :-

    repo = Repo.clone_from(
        'http://user:password@github.com/user/project.git',
        '/home/antro/Project/',
        branch='master'
    )
    

    see here for more info

    0 讨论(0)
  • 2021-01-05 19:29

    From toanant's answer.

    This works for me with the --single-branch option

    repo = Repo.clone_from( 'http://user:password@github.com/user/project.git --single-branch', '/home/antro/Project/', branch='master' )

    0 讨论(0)
提交回复
热议问题