首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >尝试从github Enterprise克隆时连接被拒绝

尝试从github Enterprise克隆时连接被拒绝
EN

Stack Overflow用户
提问于 2019-04-10 16:02:53
回答 1查看 181关注 0票数 0

我在使用git API时遇到一个错误。

代码语言:javascript
复制
from git import Repo
from github import Github

Connecting to git.xxxxx.com (port 9418) ... fatal: unable to connect to git.xxxxx.com:
git.xxxxx.com[0: 141.113.0.105]: errno=Connection refused

我可以通过命令从Enterprise github克隆代码

代码语言:javascript
复制
git clone https://[name]:[token]@git.git.xxxx.com/xxx.git

但是我混淆了git API中的克隆方式。

代码语言:javascript
复制
def walk_githubprojects(token, organization):
    client = Github(base_url='https://git.xxx.com/api/v3', login_or_token=token)
    user=client.get_user().get_repos()
    for repo in client.get_organization(organization).get_repos():
        print(repo.name)
        print(repo.git_url)
        Repo.clone_from(repo.git_url, 'my_path')

我可以在组织下获得repo名称,脚本应该将repos克隆到我的本地目录

EN

回答 1

Stack Overflow用户

发布于 2019-04-10 16:49:47

解决方案是:

代码语言:javascript
复制
from git import Repo
from github import Github


def walk_githubprojects(token, organization):

    client = Github(base_url='https://git.xxxxx.com/api/v3', login_or_token=token)
    user=client.get_user().get_repos()
    for repo in client.get_organization(organization).get_repos():
        HTTPS_REMOTE_URL = f'https://[name]:[token]@git.xxxxx.com/{repo.full_name}'
        Repo.clone_from(HTTPS_REMOTE_URL, f'/xxxx/{repo.name}')
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/55607587

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档