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

I just made a local Git repository on my computer:

~$ mkdir myproject
~$ cd myproject
~$ git init
~$ touch index.html
~$ git add index.html
~$ git commit -m 'initial commit'

Can I use any command line tools to make a new remote repository on GitHub and upload my changes? I know I can just open my browser and go to GitHub to create a new repo manually, but I want to know if there’s a way to do everything from the terminal. I’ve been searching for answers but most tutorials only show how to connect to existing remote repositories, not how to create new ones from scratch using CLI tools.

Yeah, you can totally do this with GitHub CLI. Just install gh from their site or use brew/apt. Run gh auth login to connect your account, then from your project folder use gh repo create myproject --public --source=. --remote=upstream --push. This creates the remote repo, adds it to your local project, and pushes everything in one command. I’ve been doing this for months - way faster than jumping between terminal and browser.

hub’s a solid alternative if you don’t want github cli. it’s older but still works perfectly. install it, then run hub create myproject from your repo folder - it’ll create the remote repo automatically. after that, just git push -u origin master and you’re set. i used hub for years before github cli existed.