MD XF MD XF - 2 months ago 31
Git Question

Create GitHub organization repository from command line

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' -d '{"name":"REPONAME"}'

The user then enters their username and password, and GitHub will create a new empty repository at "".

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? Thanks in advance.

kfb kfb

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 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