Creating Github repo's remotely from the Command Line

To do this we have to use the gitHub API as github provides no shell access. So using a simpe curl statement we can trigger the api to insert a new repo.

1
curl -u 'USER' https://api.github.com/user/repos -d '{"name":"REPO"}'

Remember replace USER with your username and REPO with your repository/application name!

Then we follow the usual github routine of creating a new or pushing a local repo to our newly created container on github.

Create a new repository on the command line

1
2
3
4
5
6
touch README.md
git init
git add README.md
git commit -m "first commit"
git remote add origin https://github.com/USER/NAMEOFREPOSITORY
git push -u origin master

Push an existing repository from the command line

1
2
git remote add origin https://github.com/USER/NAMEOFREPOSITORY
git push -u origin master
^