How to set up a new GitHub repository using command line without browser access?

I just finished setting up a fresh local Git repository on my machine:

$ mkdir myproject
$ cd myproject
$ git init
$ touch README.md
$ git add README.md
$ git commit -m 'initial commit'

Can I use command line tools to create a corresponding remote repository on GitHub and upload my changes? I know I could easily open my web browser and go to GitHub’s new repository page, but I’m wondering if there’s a command line approach that would let me do everything without leaving the terminal.

I’ve been searching through documentation and tutorials, but most of them assume you already have the remote repository created through the web interface. I found some guides about setting up remote Git repositories, but those methods don’t work with GitHub since they don’t offer direct shell access to their servers.

You could also automate this whole thing so you never think about it again.

I’ve got a simple automation watching my project folders - whenever I start a new Git project, it automatically creates the GitHub repo. Two minutes to set up, saves me hours of boring work.

It hits GitHub’s API, creates the repo with whatever settings you want (public/private, description, etc.), adds the remote, and pushes your first commit. You can customize it to add collaborators, set up branch protection, or configure webhooks too.

Way better than doing it manually every time. Once it’s running, you just code and everything happens behind the scenes.

Latenode makes this really easy without writing any API code yourself. https://latenode.com

yep, totally use GitHub CLI! just install gh, then do gh auth login for auth, and gh repo create myproject --public (or --private) to make the repo. after that, add it with git remote add origin and push like usual. no browser needed!