Finally, GitHub CLI is here.
With GitHub CLI 1.0, you can:
- Run your entire GitHub workflow from the terminal, from issues through releases
- Call the GitHub API to script nearly any action, and set a custom alias for any command
- Connect to GitHub Enterprise Server in addition to GitHub.com
Installation
On Mac OS GitHub CLI is available on brew
If you don’t have Homebrew already installed on your machine,
you can visit the official website or directly paste the given command in your terminal.
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
To install GitHub CLI via brew paste the given command in your terminal
brew install gh
Getting started with GitHub CLI
After you have installed gh, the next part would be to authenticate GitHub CLI which can be done by typing in this command into the terminal.
gh auth login
Choose the account you want to login to. ( Mine — Github.com )
Choose an authentication method. ( Mine — Login with a web browser )
Copy the OTP that GitHub CLI provides you and then press enter to open up Github.com on a web browser.
Enter the OTP you copied into the input field
Enable permissions and give access to connect Github.com and GitHub CLI
Type in your password and your Github.com and GitHub CLI are connected
After auth, you have to choose the default git protocol ( Mine — HTTPS )
Hurrah! GitHub CLI is ready and completely setup on your machine.
Commands
The core commands of GitHub CLI are
To know more about each core command of GitHub CLI you can just type in
gh core_command --help
An example would be
gh issue --help
and you would be getting a complete list of possible commands for each core command and you can dive deeper into each sub-command with the help of
--help
tag attached at the end of the command.
You have a plethora of commands you can execute and do everything you have been doing using GitHub using the CLI version.
A Simple Example
We will look into a simple example of creating an issue inside a Git repository.
This can be done by clicking on the Issue button and adding the title, body on Github.com but since we are using GitHub CLI we will look into how to do the same using a command line “command”.
gh issue create --title "Issue Title" --body "Issue body"
This creates an issue in your Git Repo with the appropriate title and body.
This also returns the Web URL of the issue created.
You can also get to know about other commands by using the help command.
Clap the post if you did feel helpful.
Please do have a look into my YouTube channel: Code Studio Sai Ankit that discusses everything related to coding from Computer Science Concepts, Competitive Coding tutorials, Codeforces Editorials, Development Projects.
Please also do leave a like and Subscribe to the content you like 👍.