0

I know that method, to first init an empty repo and then adding remote origin using command git remote add origin https://github.com/USER/TEST_REPO.git

for this, we first need to create remote repo at github.com manually, and then pass this url (https://github../TEST_REPO.git) into git remote add command.

I am just finding a way to create that remote repository using command, instead of manually creating from github.com.

I try to find this method at git official docs, from google, already questions asked at stackoverflow and quora etc. But I didn't find any relevant answer.

From existing Questions

From Above link, I tried command with my username and desired repo name; but It says, 'Repository not found'

git push --set-upstream https://gitlab.example.com/your-username/nonexistent-project.git master

Any kind of help will be appreciated,

1 Answers1

0

It depends on the git hosting service that you use. Most will offer an API to do this.

For example, github has a REST API that can be used to create new repositories. Example from their documentation that uses the GitHub CLI:

gh api \
  --method POST \
  -H "Accept: application/vnd.github+json" \
  /orgs/ORG/repos \
  -f name='Hello-World' \
 -f description='This is your first repository' \
 -f homepage='https://github.com' \
 -F private=false \
 -F has_issues=true \
 -F has_projects=true \
 -F has_wiki=true 
Wim Coenen
  • 66,094
  • 13
  • 157
  • 251