Since GitHub was acquired by GiantSoft, it has released a number of very useful developer tools, such as the CI/CD tools we used earlier GitHub Actions and Package packages, and today we’re going to introduce you to another useful tool that GitHub has recently released: the GitHub CLI, which allows developers to It allows developers to work seamlessly with GitHub from the command line, which means that we can pull requests, issues, and other things directly from the command line terminal. cli/cli#installation-and-upgrading) to install the GitHub CLI.
To install the GitHub CLI is very simple, for example, we can still install it here under macOS using the Homebrew tool:
Once the installation is complete, execute the
gh command directly from the command line and the installation will be complete when you see the following message.
For other platforms, just refer to the official documentation for installation: https://cli.github.com/manual/installation
Here’s an example of how to use the GitHub CLI, using issue and pull requests as two of the most popular features used by developers. Clone a project from GitHub and run the
gh command in the project directory. For example, we’ll demonstrate this under the project that we’re blogging about here: https://github.com/cnych/qikqiak.com.
We can use the
gh command to filter issues, for example, issues with the
The first time we use it, we need to authorize it once, enter the Enter key in the command line to open the authorization page in the browser, click on the authorization to.
Once the authorization is complete go back to the terminal and type enter to get the result.
The above command will filter out issues with the
Quick View Details
After finding an issue of interest, to see the details of the issue, you can quickly open the issue details page in your browser with the following command.
Creating a PR
After creating a branch and fixing the bug described in the issue after committing the code a few times, you can then use the
gh command to create a pull request to commit our contributed code.
We can also use the up and down arrow keys on the keyboard to move for action selection, to jump to the browser for action, or to submit or cancel directly.
To quickly see the status of a pull request after it has been created, you can also use the
gh command to display the review and status of the pull requests.
Here we just briefly introduce a few common commands for issue and pull requests, for more usage you can check the official documentation to learn more: https://cli.github.com/manual/examples.