Is it possible to create a remote repository on github through the terminal?

Asked

Viewed 99 times

1

Save it, guys. I’m having a doubt that I’m not finding the answer or I’m not knowing how to look.

Next, I just got into this programming universe and I’m learning git. But I came across a "weakness" that I felt should exist a more direct way.

The problem is:

Is it possible to create a repository on github via my machine terminal? (I’m not sure if these terms I’m using are correct, but I believe you’ll be able to understand what I mean)

Let me clarify the circumstances:

Every time I need to upload a local repository to the remote, I have to go there on github, create the repository and only then give the procedure of the commands "git remote add https://github.com/euArteon/test.git" etc..

What I want to know is, is there a git command that avoids this need to go on the site and create the repository? In other words, there is a command to create a remote repository through my machine’s terminal, rather than having to go there on the github website?

I searched on, but I could not find this information, maybe because I am not able to search. Actually, I don’t even know if it is possible to do this "link".

Thanks for your attention.

1 answer

1


It is possible yes (evaluate if it is worth the effort), follows below:

curl -i -u user:pass -d "{\"name\":\"test\",\"private\":true}" https://api.github.com/user/repos

It is necessary to hit the github API informing:

-i is to log the information during the request;

-u your username and password (if you only pass the username, the password will be requested in sequence);

-d to inform that some "data" will be passed, in this case a JSON with information for the creation of the repository;

URL for creating the repository - https://api.github.com/user/repos.

OBS: as are on behalf of the operating system.

More information

On the first attempt, I received an email from Git stating that the basic authentication stating the password for their API is deprecated and will soon no longer work. Along with this email came a link with an alternative, generate a token on github and use it for authentication.

Follow email:

On August 18th, 2020 at 13:04 (UTC) you used a password to access an endpoint through the Github API using Curl/7.55.1:

https://api.github.com/user/repos

Basic Authentication using a password to the API is deprecated and will soon no longer work. Visit https://developer.github.com/changes/2020-02-14-deprecating-password-auth/ for more information Around suggested workarounds and Removal Dates.

----- Updated

I tested using the token, works virtually the same:

curl -i -H "Authorization: token seu_token_aqui" -d "{\"name\":\"novo_repo\",\"private\":true}" https://api.github.com/user/repos

Instead of informing -u for the user, you must pass -H "Authorization: token seu_token".

To create the token, see here.

  • High quality answer! Thank you very much! I still don’t know how the use of api’s works, I think it’s best to keep learning the basics at first, but your instructions are very valuable and will help me a lot the moment I’m learning about. Thank you so much again!!

Browser other questions tagged

You are not signed in. Login or sign up in order to post.