GitHub CLI: Brings GitHub to the Terminal

source: github blog

GitHub CLI brings GitHub to the terminal. This is great news for all who like to use the terminal. GitHub CLI offers the following benefits without having you to leave the command line

  • Easy creation of repositories.
  • Easy creation of Pull requests.
  • Easy approval of Pull requests.
  • Easy checking of issues raised.

Let’s discuss some of the main commands.

Installation for Mac and Windows: https://cli.github.com/manual/installation

Installation for linux: https://github.com/cli/cli/blob/trunk/docs/install_linux.md

gh auth login: gh command for login.This will prompt for mode of login. I choose using a personal access token. The token can be generated by login to https://github.com/settings/tokens. Once the token is validated it shows a success message.

login steps

gh repo create <repo name>: This command will create repository in remote and local.

github before running create command
local before running create command
github after running create command
local after running create command

gh issue status: This command lists all the issues in GitHub. As a output it shows

  1. All the issues that are assigned to current user
  2. All the issues in which name of current user is mentioned
  3. All the tickets that are opened by current users
GitHub issue status

gh pr create: This command creates a new PR. While we create PR, the current local branch will be the source branch and the target branch will be the default branch. If we want to specify extra details we can pass them as an optional argument

  • - a, - - assignee login : Assign people by their login
  • -B, - - base branch: The branch into which you want your code merged
  • -H, - - head branch: The branch that contains commits for your pull request (default: current branch)

For more information you can refer to the official documentation

GitHub before running PR create command
gh pr create
GitHub after running PR create command

gh pr diff : We can see PR changes using this command

gh pr merge: This command merge the pr request. We can choose whether the local branch need to delete or not

git pr merge command
GitHub after running the merge command

You can refer all the gh command using this link https://cli.github.com/manual/

Coding, Reading,Python