如何通过github API在github中创建存储库?
我正在尝试使用 github api 在特定组织下创建存储库.我正在查看这个 站点,它讨论了如何在特定组织下创建存储库.
I am trying to use github api to create repositories under a particular organization. I was looking at this site which talks about how to create repositories under a particular organization.
Create a new repository in this organization. The authenticated user must be a member of the specified organization.
POST /orgs/:org/repos
现在我无法理解在特定组织下创建存储库所需的完整 URL 是什么?我有我的用户名和密码,可用于通过 https url 在组织下创建存储库.
Now I am not able to understand what will be my full URL that I need to use to create the repository under a particular organization? I have my username and password which I can use to create the repository under an organization through https url.
我的github实例url是这样的 - https://github.host.com
My github instance url is like this - https://github.host.com
而且我希望我的存储库在创建后是这样的 -
And I want my repository to be like this after getting created -
https://github.host.com/Database/ClientService
在组织下创建存储库的 curl 命令是什么样的?
What will be my curl command look like to create the repository under an organization?
转到设置 -> 开发者设置 -> 个人访问令牌 在 OAuth 应用程序下.现在,生成一个启用了所需权限的新访问令牌. 如果你已经有了,请忽略它.
Go to Settings -> Developer Settings -> Personal Access Token Under OAuth Apps. Now, Generate a New Access token with Required privileges enabled. Ignore This if you already have one.
在下面的命令中将 ACCESS_TOKEN
替换为 Token
并将 NEW_REPO_NAME
替换为您的新存储库 Name
:
Replace ACCESS_TOKEN
with Token
and NEW_REPO_NAME
with your New Repository Name
in the command below:
curl -H "Authorization: token ACCESS_TOKEN" --data '{"name":"NEW_REPO_NAME"}' https://api.github.com/user/repos
组织:
curl -H "Authorization: token ACCESS_TOKEN" --data '{"name":"NEW_REPO_NAME"}' https://api.github.com/orgs/ORGANIZATION_NAME/repos