Code Yarns ‍👨‍💻
Tech BlogPersonal Blog

How to create new Github repo from shell

📅 2019-Aug-27 ⬩ ✍️ Ashwin Nanjappa ⬩ 📚 Archive

Github is a popular destination to host Git repositories. New repositories can be created easily using its web interface.

The web interface is not practical if you are automating the creation of a large number of new Github repositories from the shell or from a program. The Github REST API is useful to solve this problem.

To create a new Github repository from the shell, you need this information:

We can use curl to make a Github REST API call to create a new repository using this invocation:

$ curl -u 'joe:secret_password' --header 'x-github-otp: 123456' https://api.github.com/user/repos -d "{\"name\":\"foobar_repo\"}"

The above invocation can be easily turned into a shell script to automate creation of many new Github repositories.