Create Repository in GitHub using REST API & cURL command

If you don’t know How to create Repository using REST API and cURL in Github? Then this simplified article will help you to learn about creating Repository in Github.

There are two ways to create Repository in Github. First way is using GitHub UI and second one is using GitHubAPI/cURL Lets see first one detail to understand creating repository using API.

Create Repository in GitHub using REST API

Make post call to below URL by passing request body in the form of JSON

Non-Enterprise URL :https://api.github.com/user/repos

Enterprise URL :https:/{hostname}/api/v3/orgs/{ORG_NAME}/repos

Request Body :

{
		"name":"REPO_NAME",
		"description":"DESCRIPTION",
		"homepage":"https://github.com",
		"private":false
}

Example :

create-github-repositiry-using-rest-api-and-curl
create-github-repositiry-using-rest-api-and-curl

Create Repository in GitHub using cURL command

Creating repository using cURL command is use full when you don’t want to use  GitHub UI or REST API. And also useful  for automation. You can execute cURL command from code or using Jenkin job.

Non-Enterprise URL :

curl -I -u “USERNAME:PASSWORD” https://api.github.com/user/repos-d “{\"name\":\"REPO_NAME\",\"description\":"DESCRIPTION\",\"homepage\":\"https://github.com\",\"private\":false }”

Enterprise :

curl -I -u  “USERNAME:PASSWORD” https:/{hostname}/api/v3/orgs/{ORG_NAME}/repos-d              “{\"name\":\"REPO_NAME\",\"description\":"DESCRIPTION\",\"homepage\":\"https:/{hostname}.com\",\"private\":false }”

3 thoughts on “Create Repository in GitHub using REST API & cURL command

  • I was recommended this blog by my cousin. I am no longer certain whether this publish is written via him as no one else
    recognise such unique about my difficulty. You’re incredible!
    Thank you!

    Reply
  • Your mode of explaining all in this piece of writing is
    in fact nice, every one be capable of easily be aware of it, Thanks a lot.

    Reply
  • Like!! Thank you for publishing this awesome article.

    Reply

Leave a Reply

Your email address will not be published. Required fields are marked *