如何通过 api 连接到本地 github 服务器

How to connect to local github server through api

我的办公室有一台本地服务器,我在其中安装并配置了 github 以供使用。目前我们使用 tortoise svn 连接到本地存储库并进行管理。

现在我需要使用 Github API 连接到安装在本地服务器上的 github 存储库。我知道如何使用 github API.

连接到远程 github 存储库

Currenlty 我尝试 API 请求获取云 github 存储库,使用 GET 请求 https://api.github.com/orgs/:username/repos 列出我的组织存储库,我从服务器。

[
  {
    "id": 1296269,
    "node_id": "MDEwOlJlcG9zaXRvcnkxMjk2MjY5",
    "name": "Hello-World",
    "full_name": "octocat/Hello-World",
    "owner": {
      "login": "octocat",
      "id": 1,
      "node_id": "MDQ6VXNlcjE=",
      "avatar_url": "https://github.com/images/error/octocat_happy.gif",
      "gravatar_id": "",
      "url": "https://api.github.com/users/octocat",
      "html_url": "https://github.com/octocat",      
      "type": "User",
      "site_admin": false
   },
   ...
]

同样,我想用我的本地服务器 github 回购。在我的主机文件中名为 masterhub 的本地服务器,我可以像 git clone ssh://username@masterhub/git/sample.git 一样克隆 repo,它正在工作。

我现在想要的是 我应该进行 API 调用以使 github APIs 在本地工作的端点是什么?

注:我知道 github APIs available 可以根据我的需要玩,但我只需要知道什么是我应该到达的终点吗?

GitHub Enterprise Server API 的端点与云版本略有不同。如果您的服务器的主机名是 github.example.com,则 API 在 https://github.example.com/api/v3 下可用,而不是 https://api.github.com

因此对于上面的示例,您需要使用 https://github.example.com/api/v3/orgs/:username/repos

请注意,无论您在 SSH 配置文件中配置什么在这里都无关紧要:您需要使用主机名,而不是 SSH 别名。如果您不确定该主机名应该是什么,请查看 ~/.ssh/config 并找到主机名,然后使用它。