是否有不使用子进程克隆 git 存储库的 Python 方式?我愿意使用您推荐的任何类型的模块。
最佳答案
使用 GitPython会给你一个很好的 Git 的 Python 接口(interface)。
例如,在安装之后(pip install gitpython
),你可以使用clone_from 来克隆一个新的仓库。功能:
from git import Repo
Repo.clone_from(git_url, repo_dir)
见 GitPython Tutorial有关使用 Repo 对象的示例。
注意: GitPython 需要在系统上安装 git,并且可以通过系统的 PATH 访问。
关于Python 克隆 git 存储库的方法,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2472552/