GitPython克隆存储库错误
我想用参数(GitPython克隆存储库错误,python,git,gitpython,Python,Git,Gitpython,我想用参数(--recursive,-b)克隆git存储库,但出现以下错误 Traceback (most recent call last): File "./git-clone.py", line 15, in <module> r = git.Repo.clone(repo_dir, b=branch, recursive=git_url) TypeError: unbound method clone() must be called with Repo inst
--recursive
,-b
)克隆git存储库,但出现以下错误
Traceback (most recent call last):
File "./git-clone.py", line 15, in <module>
r = git.Repo.clone(repo_dir, b=branch, recursive=git_url)
TypeError: unbound method clone() must be called with Repo instance as first argument (got str instance instead)
回溯(最近一次呼叫最后一次):
文件“/git clone.py”,第15行,在
r=git.Repo.clone(Repo\u dir,b=branch,recursive=git\u url)
TypeError:必须以Repo实例作为第一个参数调用unbound方法clone()(改为获取str实例)
这是我的密码:
#!/usr/bin/env python
import git
import os
import shutil
git_url = "<url>..."
repo_dir = "/home_local/user/git-repository"
branch = "branch"
if os.path.exists(repo_dir):
shutil.rmtree(repo_dir)
r = git.Repo.clone(repo_dir, b=branch, recursive=git_url)
#/usr/bin/env python
进口吉特
导入操作系统
进口舒蒂尔
git_url=“…”
repo_dir=“/home_local/user/git repository”
branch=“branch”
如果os.path.exists(repo_dir):
shutil.rmtree(报告目录)
r=git.Repo.clone(Repo\u dir,b=branch,recursive=git\u url)
如果我将git.Repo.clone
替换为git.Repo.clone\u from
它工作正常,但此命令不接受我的参数 试试看:
r = git.Repo.clone_from(git_url, repo_dir, branch=branch, recursive=True)
第一个参数是从何处进行克隆(远程存储库)。第二个参数是要存储克隆的位置。所有其他参数都被传递到git clone
命令。例如--branch=“branch”
和--recursive
。您可能应该坚持使用长参数名称,而不是缩写。因为递归标志存在或不存在,所以它的值只能是True或False