Github CLI -  official tool 
Tags: github, git, programming, terminal
Published: 2020-11-17 13:02:45

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](https://hub.github.com) has been serving as an unofficial powerful CLI tool for GitHub and it has been mentioned on their website also. 
<br>
But a few months ago, the company has decided to serve its purpose and came out with the official command-line tool [GitHub CLI](https://github.com/cli/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.
<br>
##Installation
The installation is very simple.
<br>
On macOS, it is available via brew 
``` 
brew install github/gh/gh
```
<br>
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
```
<br>
On Linux, it is available via `brew`. For more instructions, see the [Linux installation docs](https://github.com/cli/cli/blob/trunk/docs/install_linux.md)
<br>
##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](https://cli.github.com/manual/)

### Managing PULL REQUESTS 
For pull requests, we use `pr` along with `gh`. There are several subcommands for managing pull requests -
- <u>list</u>- this helps in listing the pull requests that have been made on the given repository.
```
gh pr list [flags]
```
- <u>status</u>- 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]
```
- <u>view</u>- 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]
```
- <u>create</u>- 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]
```
- <u>checkout</u>- 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]
```
- <u>close</u>- 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](https://cli.github.com/manual/).

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 -
- <u>create</u>- you can use the below command to create an issue. 
```
gh issue create [flags]
```
- <u>list</u>- it lists out all the issues that are currently present in the repository.
```
gh issue list [flags]
```
- <u>status</u>- check the status of the issue, whether it is closed or open
```
gh issue status [flags]
```
- <u>view</u>- it outputs the information about the issue provided by the number or URL of the issue.
```
gh issue view {<number> | <url>} [flags]
```
- <u>close</u>- it closes the issue.
```
gh issue close {<number> | <url>} [flags]
```

<br>
**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**.