Creating github repo from command line

So, I’ve been looking into git and github lately, since I need some way to keep the code I’m working on up to date and be able to see what changes I’ve made.

I like the ability to run git commands from the command line and was looking into creating a github repo from the command line.
It was way easier than I thought.

curl -u 'username' -H "X-GitHub-OTP: xxxxxx" -d '{"name":"reponame"'}

The curl -u sets the username to use and the -H “X-GitHub-OTP: xxxxxx” part is for the google authenticator that I use and the xxxxxx is the one-time code. Works great.

It calls on the api that github has and with the -d ‘{“name”:”reponame”‘} you tell github what you want to call the repo.

I set up my account with a access token also, so it is as easy as:

git init

git remote add origin

git add file

git commit -m "Your comment"

git push origin master

And with that the new repo is up and running and git is set up and ready to go. Time to push some code up on github.

Leave a Reply

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