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?
Asked
Active
Viewed 2,016 times
2 Answers
5
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)

Benjamín V
- 116
- 2
- 6
-
This looks great. If you have a link to documentation supporting your answer, [adding](https://stackoverflow.com/posts/74764582/edit) 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! – SherylHohman Dec 17 '22 at 15:14
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 git@github.com: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?

Caroline Asteria
- 94
- 3