-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!

3
  • 1
    There is an API to create repositories. Whether someone has wrapped this in a CLI tool is another question. Commented Sep 3, 2018 at 7: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. Commented Sep 3, 2018 at 7:54
  • stackoverflow.com/… Commented Sep 3, 2018 at 13:20

3 Answers 3

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
Sign up to request clarification or add additional context in comments.

1 Comment

git push needs a configured default remote, which won't be there from a straight git init; something like git remote add <name> <uri> would have to come first, which assumes the repo at the other end already exists.
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

Comments

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

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.