loading...

Meet "gh" - the Official GitHub CLI

marounmaroun profile image Maroun Maroun ・2 min read

gh is a new CLI that enables you to work seamlessly with GitHub on the command line.

As of the date of writing this post, the tool is still in its early stages of development.

Installation

brew install github/gh/gh

Features

With gh, you can create, view, and checkout pull-requests. You can also create and view issues. Let's view its options:

$ gh pr create --help
Create a pull request

Usage:
  gh pr create [flags]

Flags:
  -B, --base string    The branch into which you want your code merged
  -b, --body string    Supply a body. Will prompt for one otherwise.
  -d, --draft          Mark pull request as a draft
  -t, --title string   Supply a title. Will prompt for one otherwise.
  -w, --web            Open the web browser to create a pull request

Global Flags:
      --help              Show help for command
  -R, --repo OWNER/REPO   Select another repository using the OWNER/REPO format

Now let's create a simple PR:

$ gh pr create --base master

Creating pull request for test_branch into master in MarounMaroun/git_examples

We'll now be prompted to enter the PR title:

$ gh pr create --base master

Creating pull request for test_branch into master in MarounMaroun/git_examples

? Title My first PR from CLI!

Continuing with the prompt, we'll be asked to enter the PR's description, and finally a validation window:

? Submit?  [Use arrows to move, type to filter]
> Yes
  Edit
  Cancel

After hitting "Yes", the PR will be created for us:

Alt Text

Feel free to explore the command:

gh --help
gh pr --help
gh pr create --help
gh issue view --help
# and so on...

Posted on by:

marounmaroun profile

Maroun Maroun

@marounmaroun

Nice to meet you 🍻 My name is Maroun. I'm a dad, musician, programmer, Stackoverflower and astronaut wannabe.

Discussion

pic
Editor guide