I following a Git tutorial and I've got stuck on the creation of a new remote repository.
I've understood that the command git remote add origin would create a new repo named testingGit on https://github.com/natalisilverio/ but visiting the list of my repositories I can see that it was not created.
My intention is to learn how to create a remote repository using terminal and not in github.com. Is that possible? If if yes, what I am doing wrong?
Here follows the entire code I typed in terminal:
git init
git remote add origin https://github.com/natalisilverio/testingGit.git
git add test.rtf
git commit -m "adding test.rtf”
git remote add origin https://github.com/natalisilverio/testingGit.git
git push -u origin master (and then I provide my user and password)
remote: Repository not found.
fatal: repository 'https://github.com/natalisilverio/testingGit.git/' not found
Thank you very much
The command git remote add origin
will not create a new repository on github.
Adding a remote is simply saying "here is a URL to another copy of this repository". In order to satisfy this you would still need to have created the repository on github first.
Creating a repository on github in this way is not a common usage, but it is possible via the Github API .
More likely, you will want to create your repository first on github and then clone it locally. Or if you already have a local project, you can create a new repository on Github (via the web interface) and add your project to it. See Adding an existing project to GitHub using the command line .
As far as I know it's not possible using plain Git commands. Though in case of Github you can use Github API to do so.
This should create a new remote repository
curl -u "natalisilverio" -d "{\"name\":\"testingGit\"}" https://api.github.com/user/repos
or
curl -u "natalisilverio" -d '{"name":"testingGit"}' https://api.github.com/user/repos
*Edits
Entering this command should directly ask for the user's password. If you want to pass the password in the first command directly it can be done as below
curl -u "username:password" -d '{"name":"new-repo-name"}'
However this may leave your password in the command line history (for example in .bashhistory) so be careful.
Git command git remote add just keeps track of existing remote repositories. I does a little more than to define a variable to hold remote repository link for current local repository.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.