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"}'
The user then enters their username and password, and GitHub will create a new empty repository at "github.com/USERNAME/REPONAME".
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?
With the new github cli, it is as simple as:
gh repo create ORGNAME/REPONAME
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
:
Create
Create a new repository for the authenticated user. (Currently not enabled for Integrations)
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
(From https://developer.github.com/v3/repos/#create)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With