The [GitHub CLI] (https://cli.github.com/) is a recent GitHub released tool that takes tasks of issue / PR management to the terminal. It will be a useful tool that will put more of our workflow for software creation into the textual domain rather than the visual domain. It’s just called
**Installation of GitHub CLI 💡**
For [Windows] and [macOS], you will use the package managers to update and maintain GitHub CLI, and for Linux users, you may need to grab the software from the latest release website.
Here are examples of the installation instructions for each compatible platform:
scoop bucket add github-gh https://github.com/cli/scoop-gh.gitscoop install gh
brew install github
→ Debian/Ubuntu Linux
sudo apt install git && sudo dpkg -i gh_*_linux_amd64.deb
→ Fedora/Centos Linux
sudo yum localinstall gh_*_linux_amd64.rpm
→ Arch Linux
yay -S github-cli
**What is CLI really doing? 🤔**
The GitHub CLI lets you handle issues/ PRs / repositories from inside your console. Let’s have a look at it:
gh issue [status, list, view, create] gh pr [status, list, view, checkout, create] gh repo [view, create, clone, fork] gh help
It should be said that gh is not the same stuff as git. It’s because
gh just adds GitHub tools to the terminal. Version management is yet to be managed with git.
**CLI Commands ➫**
We’re going to cover a bunch of exciting commands. Let’s use the official Angular.js repo to run
Angular repo, and navigate to the repository. You can either clone the repo through HTTPS/ ssh/ Git CLI. I’m going to clone the repo through
git CLI since we are working on GIT CLI.
Let’s execute the
$gh issue --help see what commands are available.
gh issue --help Work with GitHub issues USAGE gh issue <command> [flags] CORE COMMANDS close: Close issue create: Create a new issue list: List and filter issues in this repository reopen: Reopen issue status: Show the status of relevant issues view: View an issue FLAGS -R, --repo OWNER/REPO Select another repository using the OWNER/REPO format INHERITED FLAGS --help Show help for command ARGUMENTS An issue can be supplied as an argument in any of the following formats: - by number, e.g. "123"; or - by URL, e.g. "https://github.com/OWNER/REPO/issues/123". EXAMPLES $ gh issue list $ gh issue create --label bug $ gh issue view --web LEARN MORE Use 'gh <command> <subcommand> --help' for more information about a command. Read the manual at https://cli.github.com/manual
It’s Time to view Problems/issues in the angular repo.😁
gh issue list
**Pull Requests 🤖**
It is now possible to build a Pull Request (PR) on the terminal. You will perform
$gh pr create right after you have committed a feature or bug branch. This interactively creates the pull request.😉
Let’s execute the
$gh pr --help see what commands are available.
Work with GitHub pull requests USAGE gh pr <command> [flags] CORE COMMANDS checkout: Check out a pull request in git checks: Show CI status for a single pull request close: Close a pull request create: Create a pull request diff: View changes in a pull request list: List and filter pull requests in this repository merge: Merge a pull request ready: Mark a pull request as ready for review reopen: Reopen a pull request review: Add a review to a pull request status: Show status of relevant pull requests view: View a pull request FLAGS -R, --repo OWNER/REPO Select another repository using the OWNER/REPO format INHERITED FLAGS --help Show help for command ARGUMENTS A pull request can be supplied as an argument in any of the following formats: - by number, e.g. "123"; - by URL, e.g. "https://github.com/OWNER/REPO/pull/123"; or - by the name of its head branch, e.g. "patch-1" or "OWNER:patch-1". EXAMPLES $ gh pr checkout 353 $ gh pr create --fill $ gh pr view --web LEARN MORE Use 'gh <command> <subcommand> --help' for more information about a command. Read the manual at https://cli.github.com/manual
**Let’s view some of it:👀**
current PR’s in the repo:
*Let’s view an individual pr:*
I’m going with the first pull request
#38899. Through gh cmd $ gh pr view
refactor(compiler): simplify visitor logic for attributes Draft • atscott wants to merge 1 commit into master from testrefactor Labels: cla: yes, comp: compiler, state: WIP, target: patch Milestone: needsTriage The logic for computing identifiers, specifically for bound attributes can be simplified by using the value span of the binding rather than the source span. View this pull request on GitHub: https://github.com/angular/angular/pull/38899
Let’s execute the
$gh repo --help see what commands are available
Work with GitHub repositories USAGE gh repo <command> [flags] CORE COMMANDS clone: Clone a repository locally create: Create a new repository fork: Create a fork of a repository view: View a repository INHERITED FLAGS --help Show help for command ARGUMENTS A repository can be supplied as an argument in any of the following formats: - "OWNER/REPO" - by URL, e.g. "https://github.com/OWNER/REPO" EXAMPLES $ gh repo create $ gh repo clone cli/cli $ gh repo view --web LEARN MORE Use 'gh <command> <subcommand> --help' for more information about a command. Read the manual at https://cli.github.com/manual
It is better to clone a repository using the gh command than with the git command. I have done this above. Only through gh cmd, I have cloned angular repo.
$ gh repo clone angular/angular $ gh repo fork - Forking angular/angular...
Start functioning. You should create a new PR after this (
$gh pr create)! It’s sort of remarkable that all of that element is now available in the terminal!😍
It is now simple to create a gist on GitHub from the terminal using the CLI cmd.
gh gist create < file >
Git CLI's primary objective is to "minimize context switching" by allowing you to continue inside your terminal/console, rather than opening your browser to access GitHub. For additional functionality and knowledge on using the current resources, you may link to the manual.