-1

I was wondering if there is a way to create repo in GitHub from local cmd and push the repo to the remote.

Like I do:

git branch IAmLocal
git push -u branch IAmLocal

It will through error as not existing repo in the remote (which is expected), as a learning I am putting this question to find a way (if there is and I not aware of it) if we could put this repo in GitHub without creating repo in GitHub manually.

Update

After seeing duplicate tag I would like to confirm that I am looking for a way where I can create remote repo and push it from local using CMD.

Happy learning!

StaticVariable
  • 396
  • 2
  • 10
  • 1
    There is an [API](https://developer.github.com/v3/repos/#create) to create repositories. Whether someone has wrapped this in a CLI tool is another question. – Richard Sep 03 '18 at 07:21
  • Your creating the bare new repo, in that case git branch IAmLocal won't work. Create the origin/master and then create your branch and then you can push the branch to the origin. – danglingpointer Sep 03 '18 at 07:54
  • https://stackoverflow.com/search?q=%5Bgithub%5D+create+repository+command+line – phd Sep 03 '18 at 13:20

3 Answers3

0

First you need to create an account on git-hub and repo

Go to the project folder and run

git init
git add .
git commit -m 'You commint message';
git push
Evgeniy Chorniy
  • 141
  • 1
  • 1
  • 11
  • `git push` needs a configured default remote, which won't be there from a straight `git init`; something like `git remote add ` would have to come first, which assumes the repo at the other end already exists. – T2PS Sep 03 '18 at 07:31
0

You can also do so:

  1. Create a git account
  2. Creating a repository
  3. Go to the project folder and run

    git clone https://github.com/USER/demo.git

USER = your user name demo.git - yout repo name

Then copy u files in this folder where u clone and run:

git add .
git commit -m 'You commint message';
git push
Evgeniy Chorniy
  • 141
  • 1
  • 1
  • 11
0

You can create a repository on GitHub using the GitHub command line API as follows:

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

Note: you need curl installed on your OS.

Another option - install this utility, then you can run many GitHub commands on your cmd. to create a new repo run this command:

$ hub create shaykia/test
Shayki Abramczyk
  • 36,824
  • 16
  • 89
  • 114