Introduction
Github recently released the beta version of their Github CLI. It’s a simple CLI tool that can be used to bring Github concepts (repo, issue, pr) into the terminal.
You can download it at https://cli.github.com/ ↗️.
Commands
After installing the cli on your system, just open the terminal and you can use any of these commands
Issue
gh issue create
It will ask you for the title and the body of the issue
Creating pull request for feature-branch into the master in owner/repo? Title My new issue? Body [(e) to launch nano, enter to skip]http://github.com/owner/repo/issues/1
Additionally, you can directly use flags to create the issue directly.
gh issue create --title "Issue Title here" --body "Issue Body here"
And you can use the web browser as well to directly open the URL to the page by adding the --web
flag
gh issue create --web
You can list the issues using
gh issue list
along with some additional flags to filter like open issues
gh issue list --state open
Pull Requests
Just like issues, you can open PR’s as well using the CLI.
gh pr create
And again it also supports using the --title
and --body
flags.
The cool part here is that you can view the status of the PR directly in the terminal.
gh pr status
Current branch There is no pull request associated with [blog/07]
Created by you You have no open pull requests
Requesting a code review from you You have no pull requests to review
Repo
Cloning a repo using CLI
gh repo clone <Owner/Repo>
Additionally, you can create new repo using
gh repo create <name>
It supports a set of flags like
-d, --description string Description of the repository --enable-issues Enable issues in the new repository (default true) --enable-wiki Enable wiki in the new repository (default true) -h, --homepage string Repository home page URL --public Make the new repository public -t, --team string The name of the organization team to be granted access
Along with creating repos, you can even fork any repo using this tool.
gh repo fork <repository>
And at the very least, open/view any repo in the browser using
gh repo view <repository>
- Note - If no
repository
is mentioned, it forks/views the current repository, that is the folder in which you are using the repo if it is initialized as a git repository remotely.
TL;DR
We talk about the latest announcement made by Github about their CLI tool and see a few examples of the commands it ships with.
Enjoying the content? Support my work! 💝
Your support helps me create more high-quality technical content. Check out my support page to find various ways to contribute, including affiliate links for services I personally use and recommend.
Conclusion
Github CLI is a great tool to use if you are a terminal person and want to do everything from the terminal itself. It’s still in beta and has a lot of features to be added. But it’s a great start and I am looking forward to using it more.