本文介绍了如何从命令行在组织下创建GitHub存储库?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

据我了解,使用GitHub v3 API在命令行上创建个人存储库,可以做到(适当替换USERNAME和REPONAME):

It's my understanding that to create a personal repository on the command line, using the GitHub v3 API, one can do this (replacing USERNAME and REPONAME appropriately):

curl -u 'USERNAME' https://api.github.com/user/repos -d '{"name":"REPONAME"}'

然后,用户输入其用户名和密码,GitHub将在"github.com/USERNAME/REPONAME"上创建一个新的空存储库.

The user then enters their username and password, and GitHub will create a new empty repository at "github.com/USERNAME/REPONAME".

我的问题是,如何通过命令行创建组织拥有的存储库?我尝试用组织名称替换USERNAME,这提示我输入主机密码".我是该组织的所有者,所以我输入了密码,但获得了错误的凭据".此方法不适用于组织拥有的存储库吗?还是我做错了什么?

My question is, how do I create an organization-owned repository via command line? I tried replacing USERNAME with the organization's name, and it prompted me for the 'host password'. I own the organization so I entered my password but I got "Bad credentials". Does this method not work for organization-owned repositories? Or am I doing something wrong?

推荐答案

要在组织下创建存储库,应将请求发送到POST /orgs/:org/repos端点而不是/user/repos.您的用户不需要任何额外的权限或范围来创建用户存储库,但用户必须是:org:

To create a repository under an organisation you should send the request to the POST /orgs/:org/repos endpoint rather than /user/repos. Your user shouldn't need any extra permissions or scopes over what is required to create a user repository, but the user must be a member of :org:

POST /user/repos

在此组织中创建一个新的存储库.经过身份验证的用户必须是指定组织的成员.

Create a new repository in this organization. The authenticated user must be a member of the specified organization.

POST /orgs/:org/repos

(来自 https://developer.github.com/v3/repos/#create )

这篇关于如何从命令行在组织下创建GitHub存储库?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-16 11:38
查看更多