2017-04-07 163 views
2

我试图从gitpytho n库中使用clone_from函数,我想将git clone参数--no-checkout传递给该命令。gitpython中的clone_from中的非值参数

根据文档,参数必须作为**kwargs传递,并且据我所知,这必须是一个字典,其中的键是git参数,值与参数值相对应。我的问题是,--no-checkout不采取任何参数值。

我已经试过类似:

clone_kwargs = {'no-checkout'} 
repo.clone_from(clone_url,local_repo_path,None,None,**clone_kwargs)'' 

clone_kwargs = {'no-checkout':''} 
repo.clone_from(clone_url,local_repo_path,None,None,**clone_kwargs) 

clone_kwargs = {'':'no-checkout'} 
repo.clone_from(clone_url,local_repo_path,None,None,**clone_kwargs) 

但所有这些尝试的失败。那么,如何最好地克隆回购没有检查出来?

回答

1

在gitpython项目This issue解释你需要做什么:

Repo.clone_from(url, to, no_checkout=True) 
你的情况这将是

所以:

repo.clone_from(clone_url, local_repo_path, no_checkout=True) 
+0

伟大的作品!非常感谢@languitar! –