create github repository from command line or console

Hi in this tutorial we will see how we can create github repository with command line or console. We can simply create repository in github with with UI and can use it. But some people like it to be created from console without visiting account via browser. It is very simple to create repository in github.

We use curl tool to create repository . When we search google then we can easily find curl command to create directory. But the problem that i faced in all the answer was problem parsing json. I found one answer that got me rid of this silly error. It was because of double quote. To remove this error we need to add backslash before every double quote.

Here is error that i was getting

json parse error

when we use  backslash before every double quote then we do not face any problem.

curl -u ‘user’ -d ‘{\”name\” : \”directory-name\” , \”description\” : \” description about directory\”}’

It will ask password of your github account and if you enter correct password then your repository will get created.

When we create directory with curl command the we get various information about this repository on console including git url ,clone url etc like this

“git_url”: “git://”,
“ssh_url”: “”,
“clone_url”: “

Now we have created repository on github we can our project add files in this repository .

Following commands will be sufficient to push your project into github

git init    initialized Git repository in current directory

git commit -m “first commit”

git remote add origin

here origin is alias name of When making changes next time we do not need to write url . we will use origin in alias of

In case you have already created origin as alias name to some other git repository then you would encounter problem like this

fatal: remote origin already exists.

To avoid this we need to remove existing repository alias from origin then need to assign  again. Here is command we use to remove existing repository from origin alias name.

git remote rm origin

then we need to again assign alias name to origin of our git repository

git remote add origin

once we have done it we need to push file into github repository with following command

git push -u origin master

Here master is the name of branch.

When making changes next time we just need following three command

git add .

git commit -m “your message for changes”

git push origin master.