Introducing Official GitHub CLI

Work seamlessly with GitHub from the command line.

Ali Bahraminezhad
ITNEXT

--

Most of us might know the hub; it was the unofficial GitHub CLI tool. Finally, GitHub released an official CLI and called it gh. The gh is a new project for us to explore what an official GitHub CLI tool can look like with a fundamentally different design. While both tools bring GitHub to the terminal, hub behaves as a proxy to git, and gh is a standalone tool.

What does gh offer?

The project is still beta and not yet released as a final product, but at the moment, you can work with issues and pull requests. That means: listing, creating, viewing.

What platforms does it support?

The project has written in the Go language, which means the project is already cross-platform. On the project repository, there are workarounds on how to install it on different OS such as Windows, macOS, Linux Distros.

How to work with gh?

Working with this tool is easy. It has only three main commands: help, issue, pr.

Working with it is easy, just executing gh in the terminal does the job.

As you can see, this tool is quite verbose, and that helps a lot. There are two main commands: issue and pr.

By executing gh issue the list of sub-commands appears:

Available Commands:
create Create a new issue
list List and filter issues in this repository
status Show status of relevant issues
view View an issue in the browser

E.g., this is how you can create a new issue:

gh issue create --title 'Yet another issue' --body 'I have an issue'

At first(and only once), it asks for authentication, and if you press Enter, it opens a new tab and asks you for your credentials.

PS D:\OSS\BlazorDebugger> gh issue create --title 'Yet another issue' --body 'Line 1 \  
>> Line 2 \
>> Line 3`
Notice: authentication required
Press Enter to open github.com in your browser...
Authentication complete. Press Enter to continue...
Creating issue in 0x414c49/BlazorDebuggerhttps://github.com/0x414c49/BlazorDebugger/issues/2

The issue created:

What’s next?

You can access the full manual on the website. It’s complete with examples. Almost every command and sub-command in gh is verbose, and whenever you need help, and you do anything wrong, it gives you the guide.

E.g., I want to see other options or flags:

gh issue list --help
List and filter issues in this repository
Usage:
gh issue list [flags]
Flags:
-a, --assignee string Filter by assignee
-l, --label strings Filter by label
-L, --limit int Maximum number of issues to fetch (default 30)
-s, --state string Filter by state: {open|closed|all}
Global Flags:
--help Show help for command
-R, --repo OWNER/REPO Select another repository using the OWNER/REPO format

The project is still beta; there might be bugs and rooms for improvements. Feel free to give GitHub feedbacks through this link.

--

--

Writer for

I’m a geek, a software engineer who likes to build amazing stuff 😉Here on Medium I write about different things but mostly focused on programming and .NET!