是否可以在不打开浏览器的情况下从 CLI 在 GitHub 上创建远程存储库? [英] Is it possible to create a remote repo on GitHub from the CLI without opening browser?

查看:24
本文介绍了是否可以在不打开浏览器的情况下从 CLI 在 GitHub 上创建远程存储库?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我创建了一个新的本地 Git 存储库:

I created a new local Git repository:

~$ mkdir projectname
~$ cd projectname
~$ git init
~$ touch file1
~$ git add file1
~$ git commit -m 'first commit'

是否有任何 git 命令来创建一个新的 远程 存储库并将我的提交从这里推送到 GitHub?我知道启动浏览器并没有什么大不了的转到创建新存储库,但如果有办法从 CLI 实现这一点,我会很高兴.

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.

我阅读了大量文章,但我发现没有一篇提到如何使用 git 命令从 CLI 创建远程存储库.Tim Lucas 的好文章 Setting a new remote git repository 是我发现的最接近的文章,但 GitHub 确实如此不提供外壳访问.

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.

推荐答案

使用 Github 的官方新命令行界面:

With Github's official new command line interface:

gh repo create

查看其他详细信息和选项安装说明.

例如,要完成您的 git 工作流程:

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

这篇关于是否可以在不打开浏览器的情况下从 CLI 在 GitHub 上创建远程存储库?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆