I created a new local Git repository:
~$ mkdir projectname
~$ cd projectname
~$ git init
~$ touch file1
~$ git add file1
~$ git commit -m 'first commit'
Is there any git command to create a new remote repo and push my commit to GitHub from here? I know it's no big deal to just fire up a browser and head over to Create a New Repository, but if there is a way to achieve this from the CLI I would be happy.
I read a vast amount of articles but none that I found mention how to create a remote repo from the CLI using git commands. Tim Lucas's nice article Setting up a new remote git repository is the closest I found, but GitHub does not provide shell access.
With Github's official new command line interface:
gh repo create
See additional details and options and installation instructions.
For instance, to complete your git workflow:
mkdir project
cd project
git init
touch file
git add file
git commit -m 'Initial commit'
gh repo create
git push -u origin master