我正在寻找在python中克隆repo的等效方法
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`
我该怎么做?
答案 0 :(得分:2)
您可以使用GitPyhton lib
从现有存储库中克隆或初始化新的空存储库:
import git
host = 'github'
user = 'root'
git.Git().clone("ssh://{0}@{1}:29418/git_performance_check".format(user, host))
答案 1 :(得分:1)
您可以使用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()
答案 2 :(得分:-1)
这是一种简单直接的方法:
import os
os.chdir(path/where/you/need/to/store/your/project)
os.system("your/git/repository.git")