Github CLI ready for your terminal.

📆 · ⏳ 3 min read · · 👀

Introduction

Github recently released the beta version of their Github CLI. It’s a simple CLI tool that can be used to bring Github concepts (repo, issue, pr) into the terminal.

You can download it at https://cli.github.com/ ↗️.

Commands

After installing the cli on your system, just open the terminal and you can use any of these commands

Issue

Terminal window
gh issue create

It will ask you for the title and the body of the issue

Creating pull request for feature-branch into the master in owner/repo
? Title My new issue
? Body [(e) to launch nano, enter to skip]
http://github.com/owner/repo/issues/1

Additionally, you can directly use flags to create the issue directly.

Terminal window
gh issue create --title "Issue Title here" --body "Issue Body here"

And you can use the web browser as well to directly open the URL to the page by adding the --web flag

Terminal window
gh issue create --web

You can list the issues using

Terminal window
gh issue list

along with some additional flags to filter like open issues

Terminal window
gh issue list --state open

Pull Requests

Just like issues, you can open PR’s as well using the CLI.

Terminal window
gh pr create

And again it also supports using the --title and --body flags.

The cool part here is that you can view the status of the PR directly in the terminal.

Terminal window
gh pr status
Current branch
There is no pull request associated with [blog/07]
Created by you
You have no open pull requests
Requesting a code review from you
You have no pull requests to review

Repo

Cloning a repo using CLI

Terminal window
gh repo clone <Owner/Repo>

Additionally, you can create new repo using

Terminal window
gh repo create <name>

It supports a set of flags like

-d, --description string Description of the repository
--enable-issues Enable issues in the new repository (default true)
--enable-wiki Enable wiki in the new repository (default true)
-h, --homepage string Repository home page URL
--public Make the new repository public
-t, --team string The name of the organization team to be granted access

Along with creating repos, you can even fork any repo using this tool.

Terminal window
gh repo fork <repository>

And at the very least, open/view any repo in the browser using

Terminal window
gh repo view <repository>
  • Note - If no repository is mentioned, it forks/views the current repository, that is the folder in which you are using the repo if it is initialized as a git repository remotely.

TL;DR

We talk about the latest announcement made by Github about their CLI tool and see a few examples of the commands it ships with.

Conclusion

Github CLI is a great tool to use if you are a terminal person and want to do everything from the terminal itself. It’s still in beta and has a lot of features to be added. But it’s a great start and I am looking forward to using it more.

You may also like

  • # git# engineering

    Selecting the Right Git Merging Strategy: Merge Commit, Squash and Merge, or Rebase and Merge

    Uncover the intricacies of Git merging strategies – merge commit, squash and merge, and rebase and merge. Discover the pros and cons of each approach and learn how to navigate the decision-making process based on your project's dynamics and team preferences.

  • # git# engineering

    Git Beyond Basics: 7 Uncommon Git Commands Every Developer Should Know

    Git is one of the most popular version control systems used by developers worldwide. However, most developers only use a handful of Git commands in their daily work. In this article, we will explore some uncommon Git commands that can help improve your workflow and productivity. These commands will help you to work more efficiently, troubleshoot issues, and collaborate more effectively with your team.

  • # git# engineering

    5 Basic Git Commands Every Developer Must Know

    Learn the top 5 basic git commands with examples that you must know as a developer in 2020.