是否有可能在不打开浏览器的情况下通过CLI在GitHub上创建远程回购? [英] Is it possible to create a remote repo on GitHub from the CLI without opening browser?

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

问题描述

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

 〜$ mkdir projectname 
〜$ cd projectname
〜$ git init
$ file file1
〜$ git add file1
〜$ git commit -m'first commit'

是否有任何git命令来创建新的远程 repo,并将我的提交从此处推送到GitHub? I知道启动浏览器并转向创建新的存储库并不重要,但如果存在从CLI中实现这一点我会很高兴的。

我阅读了大量的文章,但没有提到如何使用CLI创建远程repo git命令。 Tim Lucas的漂亮文章建立一个新的远程git仓库是我发现的最接近的,但是GitHub的确如此不提供shell访问。

解决方案

您可以使用GitHub API通过命令行创建GitHub repo。查看存储库API 。如果您向下滚动约三分之一,则会看到一个标题为创建的部分,它解释了如何通过API创建一个回购协议(上面是一个解释如何用API分发回购协议的部分)。显然,你不能使用 git 来做到这一点,但你可以通过命令行使用 curl



在API之外,无法通过命令行在GitHub上创建回购站。正如你所说的,GitHub不允许shell访问等,所以除了GitHub API之外,创建回购的唯一方法是通过GitHub的web界面。


I created a new local Git repository:

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

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.

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.

解决方案

You can create a GitHub repo via the command line using the GitHub API. Check out the repository API. If you scroll down about a third of the way, you'll see a section entitled "Create" that explains how to create a repo via the API (right above that is a section that explains how to fork a repo with the API, too). Obviously you can't use git to do this, but you can do it via the command line with a tool like curl.

Outside of the API, there's no way to create a repo on GitHub via the command line. As you noted, GitHub doesn't allow shell access, etc., so aside from the GitHub API, the only way to create a repo is through GitHub's web interface.

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

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