我希望允许用户通过提供其系统上库的url来克隆github仓库。我找到了api,但它没有在没有github凭据的情况下工作。有没有其他方法可以使用python克隆存储库而不提供github凭据?
您需要生成Git SSH key,然后可以像这样做:
import os
os.system("GIT_SSH_COMMAND=\"ssh -i <insert your git private key here>\" git clone ssh://git@github.com/<username>/<repo>.git")
看看这个库 gitpython - https://gitpython.readthedocs.io/en/stable/
下面是一个示例帮助您克隆:
import git
git.Git("/your/directory/to/clone").clone("git://gitorious.org/git-python/mainline.git")
git clone <url>
命令吗? - glotchimo