how to add a remote repo using gh cli?
Asked Answered
P

2

7

I'm using the github cli (GH), and I have an already created repo, and a local git repo, is there a way to add a remote repo for that git repo using the gh cli?

Phonology answered 19/9, 2022 at 19:14 Comment(0)
C
15

It appears that the CLI doesn't have a command to create it directly, but it's possible to do it with the repo view command:

git remote add origin $(gh repo view $repo --json sshUrl --jq .sshUrl)
Calvities answered 11/12, 2022 at 21:15 Comment(1)
This looks great. If you have a link to documentation supporting your answer, adding that you your post as an edit would be an excellent upgrade to your answer. This would increase the likelihood visitors will follow up to learn about this feature, and help users out so everyone doesn't have to try running the same searches for it. Adding a supporting link could even garner a few additional upvotes from users. Either way, thanks for your solution!Psychodrama
A
0

you can try this steps

curl -u 'nyeates' https://api.github.com/user/repos -d '{"name":"projectname","description":"This project is a test"}' 
git remote add origin [email protected]:nyeates/projectname.git  
git push origin master

maybe you can find the other reference in here : Is it possible to create a remote repo on GitHub from the CLI without opening browser?

Anisotropic answered 20/9, 2022 at 0:54 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.