0

I am writing a script that needs to create a repo. I would like it to be fully automatically and avoid users (assuming users all have github setup locally) creating a remote repo in github manually. Is it possible I can create a repo using only git CLI from local?

To start with test-folder:

mkdir test-folder; cd test-folder; touch REAMDE.md
git init .
git add .
git commit -m 'initial commit'
# Do not have an existing repo remotely in github.com
# git remote add origin 
# git push origin master
WenliL
  • 419
  • 2
  • 14

1 Answers1

0

The Git CLI itself does not support this, since it has no knowledge about Github or other repository providers.

However, Github offers a CLI tool as well (documentation here: https://github.com/cli/cli), which has a command to create repositories:

gh repo create [<name>] [flags]

Documentation: https://cli.github.com/manual/gh_repo_create

dunni
  • 43,386
  • 10
  • 104
  • 99
  • Thanks for the nice solution. I can now create a repo in the github using `gh`. I assume I can now just use `git clone` to copy the repo from remote to local. Do you know how to get the url automatically? – WenliL Jan 12 '22 at 19:42