BT

InfoQ Homepage News New GitHub CLI Enables Working with Issues and PRs from the Command Line

New GitHub CLI Enables Working with Issues and PRs from the Command Line

Bookmarks

GitHub has just beta-released GitHub CLI, an open-source tool that allows developers to work with issues and pull requests from the command line. Written in Go, GitHub CLI can be installed on Linux, macOS, and Windows.

Using GitHub CLI, developers will be able to list open issues and filter them based on assignee, label, and state; to create pull requests; to check out pull requests locally; to view the status of your work, and more.

For example, to check out a pull request locally, you can run:

gh pr checkout <PR-number>

This will create a local branch with the changes included in the PR. Similarly, you can create a pull request using:

gh pr create

After running this command, GitHub CLI will gather title and description from the command line and create the PR remotely. Alternatively, you can specify title and description using specific flags:

gh issue create -t "Pull request title" -b "Pull request body"

If you know a pull request number, you can access its summary from the command line using:

gh issue view <PR-number> --preview

As mentioned, you can also list issues and pull requests. To list the most recent open issues, you can run issues list, which also supports filtering options:

gh issue list
gh issues list --label "critical"

Similarly, you can list and filter pull requests:

gh pr list --state closed --assignee user

A final command provided by GitHub CLI is status, which displays a summary view of your work, including the status of your branch, open pull requests, and pull requests for which you are required as a reviewer.

GitHub CLI is meant to work alongside git command line tool and not to replace it for Git-specific workflows.

Prior to GitHub CLI, the semi-official hub tool already attempted to provide command line-based access to GitHub issues and pull requests. hub, though, took a radically different approach than GitHub CLI by opting for wrapping git commands in addition to providing means to work with GitHub specific features. hub maintainer Mislav Marohnić wrote a thorough recount of his experience developing hub, including hints at its future now that GitHub has its own official CLI tool.

As it is usual, GitHub's announcement sparked a number of reactions from the developer community. Besides positive remarks, several developers criticized the limitations of GitHub CLI current implementation. Those include for example the limited number of results returned by listing and filtering; the absence of a local replica of issues and PR data, which makes using the tool slow; and the difficulty of integrating it in automated workflows alongside other command line tools.

Rate this Article

Adoption
Style

Hello stranger!

You need to Register an InfoQ account or or login to post comments. But there's so much more behind being registered.

Get the most out of the InfoQ experience.

Allowed html: a,b,br,blockquote,i,li,pre,u,ul,p

Community comments

Allowed html: a,b,br,blockquote,i,li,pre,u,ul,p

Allowed html: a,b,br,blockquote,i,li,pre,u,ul,p

BT

Is your profile up-to-date? Please take a moment to review and update.

Note: If updating/changing your email, a validation request will be sent

Company name:
Company role:
Company size:
Country/Zone:
State/Province/Region:
You will be sent an email to validate the new email address. This pop-up will close itself in a few moments.