As of January 2020, GitHub reports having over 40 million users and more than 100 million repositories(including at least 28 million public repositories), making it the largest host of source code in the world. (Wikipedia)
As with any successful modern tool, Github is extremely extensible. It offers a great variety of ways to customize it, extend it, and integrate it with other tools.
But still, you might wonder — Why do we need a GitHub CLI while we already have a rich set of CLI commands with the Git CLI itself?
The main reason here is that the GitHub platform provides way more features than those available in Git version control. Plus, you can argue, we should not have to think of Git and Github as separate tools since the latter uses the former and extends its functionality.
GitHub already had a CLI called Hub maintained by one of GitHub’s employees. But they later decided to create this official project from the ground up rather than extending the Hub project, as discussed in the CLI vs. Hub article.
GitHub CLI brings the GitHub to the terminal. GitHub team releases version 1.0 in September 2020, and CLI helps developers create automated scripts for their workflows. With GitHub CLI you can;
You can perform repository related tasks using GitHub CLI, such as creating, cloning, and fork repositories. If you need any help, use the GitHub CLI --help
command parameter, as shown below.
gh repo --help
To clone a repository from GitHub, you can use the following command.
gh repo clone owner/repo
Figure 1 — Clone Repository
Using GitHub CLI, you can create Issues. This feature gives you the ability to automate the Issue creation with pre-defined templates, labels and even assign developers as required. GitHub CLI also supports interactive inputs so that you can create Issues with guidance without opening the browser.
gh issue create
Figure 3 — Create a GitHub Issue
Also, you can list issues with the command shown below.
gh issue list
Figure 2 — List GitHub Issues
GitHub CLI provides a rich set of features around Pull Requests. Let’s look at a few essential tasks you can do with Pull Requests.
gh pr create
Figure 4 — Create Pull Request
After you create the Pull Request, you can approve and review it from GitHub CLI. This feature becomes handy for scenarios where you need to analyze code and change PR’s status accordingly. It also provides the ability to approve the Pull Request if it meets specific criteria using CI/CD. Besides, you can merge the changes into the branch, as shown below.
gh pr merge
Figure 5 — Merge Pull Request
In addition to these CLI commands, the list of options available with Pull Request is quite long. I’ll leave them for you to discover. You can follow the official documentation for more information.
#web-development #github #javascript #programming #developer