GitHub open source command line tool official summit TOP1,5 minute speed to get started!

The official version of GitHub CLI has finally come out, they rushed upon open source washed up on GitHub Trending list TOP1, then, let us look at how you can get started quickly CLI Fun in just 5 minutes!

Author | Nabil Nalakath

Translator | meniscus, Zebian | TANG lead

Head map | CSDN

Exhibition | CSDN (ID: CSDNnews)

Over the years, as the world's most popular code hosting platform GitHub has not even provided the official CLI tool. GitHub open source project, after all, is the most commonly used platform will make people feel surprised.

But become part of the open source ecosystem advantage is that, with or without official support, the community will build the appropriate tools when needed, GitHub will have the same experience.

Hub is the most popular unofficial GitHub CLI. According to its website: ". Hub is an extension of the command line Git can help you through the daily work of GitHub without leaving the terminal."

I have to admit, this tool has fulfilled its commitment. Recently, however, GitHub has been doing for the publication of official efforts to tools and products, and their good progress, which also thanks to the huge amounts of money and adjust the direction of Microsoft's acquisition brings.

Before, GitHub released a desktop application with a GUI, and a command-line tool also formally put on the agenda. Today, the official version of GitHub CLI has finally come out.

GitHub CLI

GitHub CLI is the official version of the command-line tool, currently in beta testing.

Although this tool has not been officially released, but given the attention of developers and GitHub, I have to say that the beta release just around the corner. Let's take a look at this tool and how to use in their daily work.

installation

Github CLI installation is very simple and straightforward.

For the macOS:

brew install github/gh/gh

For Windows, there are three methods of installation, one of which is as follows:

scoop bucket add github-gh https://github.com/cli/scoop-gh.git
scoop install gh

You can also get Chocolately, simply run:

choco install gh

最后,如果你需要 MSI 安装程序文件,则可以前往发行页面(https://github.com/cli/cli/releases/tag/v0.5.7),下载所需的文件。

命令

截止到目前为止,GitHub 已发布了 Beta 版的 CLI,其中包含两个主要命令:issue 和 pull request。因为这两个是开源社区中开发人员最常用的命令。

虽然 hub 支持更多命令,但 hub 只是 Git 的代理,而 gh 是独立的工具。

由于是官方的工具,所以我们希望可以看到更多的命令,但首先让我们了解一下现有的命令。CLI 中所有的命令均以 gh 开头。

Issue

issue 命令用于处理 GitHub 上与 issue 相关的所有事宜。issue 有四个子命令:create、list、status 和 view。具体语法是:gh issue <子命令>。

下面让我们来看看这四个命令:

  • create:从命令行创建 issue 非常简单。你可以直接使用带有 title 和 body 标签的命令:

gh issue create --title "Issue title" --body "Issue body"

也可以通过交互的方式输入详细信息。它还提供了选项可以直接提交 issue,也可以在浏览器中打开链接,供你进行代码审查和提交问题。

  • list:list 命令用于列出代码库中当前的 issue。命令为:gh issue list。它还有过滤器,你可以根据 assignee、label、current state(open、closed)等条件过滤列表。

示例如下:

不带过滤的 issue 列表

closed 的 issue 列表

  • status:这个命令仅显示与当前用户有关的 issue 的状态。命令很简单:gh issue status。

显示相关 issue 的状态

  • view:这个命令是在浏览器中快速打开问题的快捷方式。你只需输入命令,然后输入 issue 的编号,即可在浏览器中打开这个 issue,例如:gh issue view 6。

PR

PR 是 Pull Request 的缩写,它是 CLI 中的第二大主要命令。

你可以利用 PR 直接从命令行处理 GitHub 拉取请求,它也有四个子命令:create、list、status、view,还有一个附加的子命令:checkout。语法为:gh pr <子命令>。

  • checkout:该命令用于从 Git 中检出拉取请求。你可以通过拉取请求编号或 URL 检出。用法为:gh pr checkout { <number> | <url>}。该命令可以立即从拉取请求中检出到新分支。

pr checkout

  • create:顾名思义,用于从 CLI 创建拉取请求。用法为:gh pr create [flags]。该命令有很多标志,例如 title、body、branch 等。你可以在 pr 中添加详细信息并选择要与之合并的分支。它还允许使用以下标志输入信息:

gh pr create --title "Pull request title" --body "Pull request body" 

或者,你也可以使用交互式 CLI。它还提供了选项可以直接提交问题,也可以在浏览器中打开其链接,供你进行代码审查和提交。

从命令行创建 pr

  • list:该命令可以列出代码库当前的拉取请求。命令为:gh pr list。它还有过滤器,你可以根据 assignee、label、current state(open、closed)等条件过滤列表。示例如下。

列出代码库中的 pr

  • status:这个命令仅显示与当前用户有关的 issue 的状态。具体命令为:gh pr status。它可以按照各个条件显示这些信息:Current branch、Created by you 以及 Requesting a code review from you。

pr 状态

  • view:这个命令是在浏览器中快速打开 pr 的快捷方式。你只需输入命令,然后输入 pr 编号,即可在浏览器中打开这个 issue,例如:gh pr view 6。此外,你也可以使用--preview 标志在浏览器中快速预览。

总结

以上,我们快速浏览了 GitHub 官方 CLI 的命令,更多信息请参阅官方页面的详细文档。相信正式发布时,还会添加更多命令。

GitHub CLI 官方地址:https://cli.github.com/

英文:The Official GitHub CLI Is Here

链接:https://medium.com/better-programming/the-official-github-cli-is-here-9fb7276e2e15

作者:Nabil Nalakath

译者:弯月

【End】

《原力计划【第二季】- 学习力挑战》

正式开始

即日起至 3月21日

千万流量支持原创作者

更有专属【勋章】等你来挑战

推荐阅读 

微信小程序直播正式公测;刘强东 2020 年已卸任 8 家公司高管;React 16.13.0 发布| 极客头条

高通发布 5G 基带芯片 X60:5nm 制程,2021 年上市

先马后看!详解线性回归、朴素贝叶斯、随机森林在R和Python中的实现应用!(附代码)

近一半程序员单身、年薪低于 15 万,程序员扎心现状大调查!

看完就能独自把集群搭起来!Hadoop HDFS完全分布式环境搭建以及技术详解

36万美元套利!3 个步骤揭秘黑客DeFi闪电贷操盘全过程

你点的每一个在看,我认真当成了喜欢

发布了1763 篇原创文章 · 获赞 4万+ · 访问量 1595万+

Guess you like

Origin blog.csdn.net/csdnnews/article/details/104586290