3

I'm trying to create a GitHub repo using the command line.

It was suggested here that you can use the following command:

curl -u 'USER' https://api.github.com/user/repos -d '{"name":"REPO"}'
# Remember replace USER with your username and REPO with your repository/application name!
git remote add origin git@github.com:USER/REPO.git
git push origin master

When I use it, I'm prompted to enter my password (which I am positive is correct as I can log in successfully on the GitHub.com). I then receive this error:

c:\Development\Projects\MovieStar>curl -u 'jonnymaceachern' https://api.github.com/user/repos -d '{"name":"MovieStar"}'
Enter host password for user ''jonnymaceachern'':
{
  "message": "Bad credentials",
  "documentation_url": "http://developer.github.com/v3"
}

I've tried with no quotes around my username and it just gives me a "Problems parsing JSON" error.

Community
  • 1
  • 1
Jonny
  • 860
  • 3
  • 12
  • 32

2 Answers2

1

git@github.com:USER/REPO.git is an ssh url, not an https one.
The "password" GitHub is asking you is because ssh doesn't find your public/private keys, and has nothing to do with your GitHub account password.

Use:

git remote add origin https://YourName@github.com/YourName/REPO.git
git push -u master

Then it will ask you for your http credentials.
If you don't want to enter it for each transaction, see "Is there a way to skip password typing when using https:// github".

Community
  • 1
  • 1
VonC
  • 1,042,979
  • 435
  • 3,649
  • 4,283
0

What I would do :

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

Tested OK on my github account. That way, you will not be prompted to type your password. It that doesn't work, maybe your password is not the good one (or username).

Gilles Quenot
  • 143,367
  • 32
  • 199
  • 195
  • Still getting the same error. Even logged into GitHub to change my password and try again. Using my email in the username field doesn't work either. – Jonny Dec 07 '13 at 16:58
  • This will leave your password in your shell history. OP's command is perhaps better in this regard. – Aidan Miles Jan 24 '14 at 19:36