问题描述
我试图用python函数中的GitPython从git中克隆一个仓库。
我使用GitPython库从git中克隆了我的python函数和我的代码片段,如下所示:
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:
Repo.clone_from('',
/ home / antro / Project /')
Repo.clone_from('http://user:[email protected]/user/project.git', /home/antro/Project/')
它从主分支克隆。我如何使用GitPython从其他分支进行克隆,或者有任何其他库可以从各个分支进行克隆?请让我知道。
It clones from master branch. How do I clone from other branch using GitPython or any other library is available to clone from individual branches? Please let me know.
通过在命令行中提及分支,我知道克隆使用
I am aware of clone by mentioning branch in commandline using
git clone -b分支
git clone -b branch http://github.com/user/project.git
推荐答案
只需传递分支名称参数,例如: -
just pass the branch name parameter, e.g. :-
repo = Repo.clone_from(
'http://user:[email protected]/user/project.git',
'/home/antro/Project/',
branch='master'
)
请参阅
这篇关于如何使用Gitpython从Git的特定分支进行克隆的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!