GitHub CLI brings GitHub to your terminal. Finally GitHub CLI is out of beta and now available for download on Windows, macOS and Linux platforms.
It reduces context switching, helps you focus, and enables you to more easily script and create your own workflows. And it's free and open source.
So what you can do using GitHub CLI 1.0 :
- 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
Using GitHub CLI v1.0 - From issue to release
Use GitHub CLI for your entire GitHub workflow.
- Clone the repository you want to work with using gh repo clone owner/repo.
- Find the next thing you need to work on with gh issue status or gh issue list --assignee Jhon Doe.
$ gh issue list
$ gh issue list
Showing 4 of 4 issues in cli/cli
#16 Improving interactions with protected branches
#14 PR commands on a detached head
#13 Support for GitHub Enterprise (enhancement)
#8 Add an easier upgrade command (bug)
- When you’ve finished adding that feature or fixing that bug, use
gh pr create
to create your pull request on GitHub.
$ gh pr create
Creating pull request for feature-branch into main in ampinsk/test
? Title My new pull request
? Body [(e) to launch vim, enter to skip]
? What's next? Submit
http://github.com/owner/repo/pull/1
- And your teammate can check out your pull request using
gh pr checkout 1337
, view the diff withgh pr diff
, and even provide a lightweight review usinggh pr review
.
$ gh pr status
Relevant pull requests in cli/cli
Current branch
There is no pull request associated with [fix-homepage-bug]
Created by you
You have no open pull requests
Requesting a code review from you
#100 Fix footer on homepage [fix-homepage-footer]
✓ Checks passing - Review pending
$ gh pr checkout 12
remote: Enumerating objects: 66, done.
remote: Counting objects: 100% (66/66), done.
remote: Total 83 (delta 66), reused 66 (delta 66), pack-reused 17
Unpacking objects: 100% (83/83), done.
From https://github.com/owner/repo
* [new ref] refs/pull/8896/head -> patch-2
M README.md
Switched to branch 'patch-2'
- After the pull request is approved, you can make sure all your tests are passing with
gh pr checks
, and then go ahead and merge it right from your terminal withgh pr merge
. GitHub CLI will even offer to delete your branch locally and on GitHub.com after the merge.
$ gh pr checks
All checks were successful
1 failing, 3 successful, and 1 pending checks
- CodeQL 3m43s https://github.com/cli/cli/runs/123
✓ build (macos-latest) 4m18s https://github.com/cli/cli/runs/123
✓ build (ubuntu-latest) 1m23s https://github.com/cli/cli/runs/123
✓ build (windows-latest) 4m43s https://github.com/cli/cli/runs/123
× lint 47s https://github.com/cli/cli/runs/123
$ gh pr merge
$ gh pr merge
? what merge method would you like to use? Create a merge commit
? Delete the branch locally and on GitHub? Yes
✓ Merged pull request #23 (Remove beta label)
✓ Delete branch remove-beta and switched to branch main
- And when you’re ready to cut your next release, just use
gh release create [tag name]
and make your creation available to the world without ever leaving your command line!
Make GitHub CLI your own with aliases and gh api
- GitHub CLI now allows you to create aliases for any command using
gh alias set
. And with the powerfulgh api
allowing you to access the GitHub API directly, there’s no limit to what you can do withgh
. Commands are also easily composable. - to share your aliases with a gist, you can use
gh alias list | gh gist create
.
GitHub CLI is available for GitHub Enterprise Server
- Finally, you can use GitHub CLI with repositories hosted on GitHub Enterprise Server 2.20+.
Here some links where you can checkout features of GitHub CLI:
- create and view repositories
- configure GitHub CLI to use SSH and your preferred editor
- close, reopen, and add labels, assignees, and more to issues and pull requests, and
- view the diff, review, and merge pull requests
If you like this article then write me on twitter and share with other people.
Read my previous article Dark mode with 1 CSS property here.
What's new in ECMAScript ES2020 new features
Source: GitHub.