用python下载git文件夹工具?

2024-10-02 20:42:16 发布

您现在位置:Python中文网/ 问答频道 /正文

有一个很好的git文件包吗?在

示例

getsomething = {
    'htmlpurifier' : 'http://repo.or.cz/w/htmlpurifier.git'
}

for key in vendors:
    # someutility.get(http://repo.or.cz/w/htmlpurifier.git,htmlpurifier)
    someutility.get(vendors[key],key) 
    # get http://repo.or.cz/w/htmlpurifier folder to /htmlpurifier  on localstorage ?

是否有相似之处?


Tags: or文件keyingithttp示例for
2条回答

我更喜欢直接使用git命令,并使用subprocess模块包装它。在

但是,如果您正在寻找与Git交互的模块,我可以想到

特别是对于gitpython,请查看类:Repo。它有一个功能:

fork_bare(path, **kwargs)  
Fork a bare git repository from this repo 
path is the full path of the new repo (traditionally ends with name.git)  
options is any additional options to the git clone command 
Returns git.Repo (the newly forked repo)

您还可以签出:http://packages.python.org/GitPython/0.3.2/tutorial.html#using-git-directly

^{pr2}$

GitPython is a python library used to interact with git repositories

GitPython docs

如果您所说的“git folder download”是指克隆git存储库,那么应该这样做:

from git import Repo
repo_url = "http://repo.or.cz/w/htmlpurifier.git"
local_dir = "/Users/user1/gitprojects/"
Repo.clone_from(repo_url, local_dir)

相关问题 更多 >