[英]How to clone a git repo using python?
我正在寻找在python中克隆存储库的等效方法
clone_start=`date +%s%N` && git clone --quiet ssh://$USER@$host:29418/git_performance_check >& /dev/null && c
lone_end=`date +%s%N`
Time_clone=`echo "scale=2;($clone_end - $clone_start) / 1000000000" | bc`
我该怎么做 ?
您可以使用GitPyhton lib
从现有存储库克隆或初始化新的空存储库:
import git
host = 'github'
user = 'root'
git.Git().clone("ssh://{0}@{1}:29418/git_performance_check".format(user, host))
您可以使用GitPython
。 像这样:
from git import Repo
repo = Repo.init('/tmp/git_performance_check')
repo.create_remote('origin', url='ssh://user@host:29418/git_performance_check')
repo.remotes.origin.fetch()
这是简单明了的方法:
import os
os.chdir(path/where/you/need/to/store/your/project)
os.system("your/git/repository.git")
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.