ses
ses

Reputation: 13342

Create new repo by 'git remote add origin' and 'push'

When creating a local repo and trying to push it to github, ending up with an issue:

ERROR: Repository not found.
fatal: The remote end hung up unexpectedly

My steps are standard - that what gitHub Help suggests to go with.

touch README.md
git init
git add README.md
git commit -m "first commit"
git remote add origin [email protected]:MyUser/my-samples.git
git push -u origin master

Then: git push -u origin master

Q: How can I push new repo/branch to the github?

Just clarifying: I wan to create New repository from command line remotely - it does not exist yet on my github.

Basically I'm trying to perform 11th step on http://try.github.io/

Btw. when I try to use https:// instead of just [email protected]:... (following that steps) I end up having 403 error.

If I use "ssh://", adding my keys on github, I end up having Repository not found error. But that test sh -T [email protected] passes successfully,

So UPDATE: yes I've checked my connection.

Upvotes: 3

Views: 2143

Answers (2)

ses
ses

Reputation: 13342

So, I guess a simple answer is: it is impossible to create repo remotely by git remote add and push command.

Thus, when I do: git remote add origin [email protected]:MyUser/my-samples.git

It does NOT mean it is going to create NEW repo on the REMOTE host. It means it is going to link my origin master branch to remote one, which is supposed to be existing at that moment.

Then, probably there is an command that would create a repo/project remotely.

But it is different one - not git remote add .. and then push.

That being said, I consider +Akash Agrawal's corrent. Answering my question just to make it clear for myself.

--

That answers my question how to create it remotelly from command line: Is it possible to create a remote repo on GitHub from the CLI without opening browser?:

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

Or HUB: http://hub.github.com/

# create a repo for a new project
$ git init
$ git add . && git commit -m "It begins."
$ git create -d "My new thing"
→ (creates a new project on GitHub with the name of current directory)
$ git push origin master

Upvotes: 3

Akash
Akash

Reputation: 5221

You will need to create a repo on github to be able to push your changes to it. Bare repos are not initialized automatically. Otherwise spelling mistakes can lead to undesirable creation of new repos.

Upvotes: 1

Related Questions