是否可以在不打开浏览器的情况下从 CLI 在 GitHub 上创建远程存储库?

编程入门 行业动态 更新时间:2024-10-07 00:12:29
本文介绍了是否可以在不打开浏览器的情况下从 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 上创建远程存储库?

本文发布于:2023-11-12 21:15:25,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1582543.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:情况下   打开浏览器   GitHub   CLI

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!