Github is the most amazing, powerful platform for developers, engineers, and even for organizations as well for serving as a home to millions of projects including open source and some personal projects as well.
Being a terminal lover, working on the terminal is fascinating. Hub has been serving as an unofficial powerful CLI tool for GitHub and it has been mentioned on their website also.
But a few months ago, the company has decided to serve its purpose and came out with the official command-line tool GitHub CLI so that you don't have to leave your terminal.
The tool was in the beta stage until September. Then it has been released with its first version v1.0.
Installation
The installation is very simple.
On macOS, it is available via brew
brew install github/gh/gh
On Windows, it is available via three methods :
- Scoop
scoop bucket add github-gh https://github.com/cli/scoop-gh.git
scoop install gh
- WinGet
winget install gh
- Chocolatey
choco install gh
On Linux, it is available via brew
. For more instructions, see the Linux installation docs
Commands
While hub already supports more commands, hub behaves as a proxy to Git and gh
is a standalone tool.
All commands in the CLI start with gh
.
I have stated several commands for pull requests and issues. For more commands, you can check upon this Manual
Managing PULL REQUESTS
For pull requests, we use pr
along with gh
. There are several subcommands for managing pull requests -
- list- this helps in listing the pull requests that have been made on the given repository.
gh pr list [flags]
-
status- this tells us about the status of the active
pr
, we can provide the info of the requests for which we want to check the status.
gh pr status [flags]
- view- this command is used to view the pull request, title, the code along with the pr, body, etc.
gh pr view [<number> | <url> | <branch>] [flags]
-
create- as the word suggests, this command is used to create a pull request. You can use different flags like title body etc. to
pr
, just go and check the manual for flags.
gh pr create [flags]
- checkout- this command is used to check out a pull request using the pull request number or URL if you have it.
gh pr checkout {<number> | <url> | <branch>} [flags]
- close- this command closes the pull request provided the pull request number, URL which you want to close.
gh pr close [<number> | <url> | <branch>] [flags]
For more commands related to managing the Pull requests, you can check out this.
The [flags] part generally represents the parameters values you want to provide with the command. You can check the manual for that.
ISSUES
We use the issue
command with gh
to deal with issues on GitHub.There are several commands that are used with issue command -
- create- you can use the below command to create an issue.
gh issue create [flags]
- list- it lists out all the issues that are currently present in the repository.
gh issue list [flags]
- status- check the status of the issue, whether it is closed or open
gh issue status [flags]
- view- it outputs the information about the issue provided by the number or URL of the issue.
gh issue view {<number> | <url>} [flags]
- close- it closes the issue.
gh issue close {<number> | <url>} [flags]
NOTE- Just don't get confused with the flags part, I have provided the link for the manual above. Go and check out and add flags as per your need.
Top comments (0)