If you're a developer, you live in the terminal. It's your cockpit, your control center. You git commit
, git push
, and ssh
into servers with muscle memory. But when it's time to review a pull request, merge a branch, or create an issue, you likely break your flow, switch to your browser, and navigate to GitHub.com.
What if you could manage your entire GitHub workflow without ever leaving the command line? Enter GitHub CLI, or gh
.
GitHub CLI is an open-source tool that brings the entire GitHub experience right to your terminal. It’s more than just a convenience; it’s a paradigm shift that can dramatically enhance your productivity and streamline your development process.
gh
)?gh
is a command-line tool that allows you to interact with GitHub. Instead of clicking through a web interface, you can execute commands to perform almost any action you can do on the website. It’s designed to work seamlessly with git
, understanding your local repository context to make commands intuitive and powerful.
Think of it as the missing link between your local git
commands and the collaborative features of GitHub.
gh
Todaygh
eliminates the disruptive jump from your IDE and terminal to your browser. You can create PRs, check CI status, and manage issues while staying firmly in your coding zone.gh
can be easily integrated into scripts. You can automate complex workflows, like automatically creating a PR when you push a new branch, or generating a report of all open issues.gh
is built to be a companion to git
. It automatically knows which repository you're in, what branch you're on, and uses that information to simplify commands. For example, if you’re on a feature branch, gh pr create
will automatically suggest using that branch for the pull request.gh
is fully interactive. It can open lists of issues and PRs in a scrollable, interactive mode. It can even help you set the title and body for a new pull request by opening your default text editor.Getting gh
up and running is straightforward.
brew install gh
winget install --id GitHub.cli
sudo apt install gh
or see the official docs for other distributions.gh
Commands to KnowHere are some of the most powerful and frequently used commands that will change how you work.
gh pr create
: Creates a new pull request for the current branch. It will open your editor to write a title and description and can even suggest the base branch.gh pr list
: Lists all pull requests in the repository.gh pr checkout <pr-number>
: Fetches and checks out the branch for a specific pull request. Incredibly useful for reviewing colleagues' code.gh pr merge <pr-number> --squash
: Merges the specified pull request using a squash merge.gh issue create
: Creates a new issue.gh issue list
: Lists and filters open issues.gh issue view <issue-number>
: Shows details for a specific issue.gh repo create
: Creates a new repository on GitHub, and can even push your local repository upstream in one step.gh repo view --web
: Opens the current repository's page on GitHub in your browser. A handy shortcut!gh api
:
For power users, the gh api
command is a game-changer. It allows you to make authenticated calls to the GitHub API directly from the CLI, giving you access to every single feature. For example, you can trigger a GitHub Actions workflow:
bash
gh api -X POST /repos/{owner}/{repo}/actions/workflows/{workflow_id}/dispatchesLet's see how gh
transforms a common task:
The Old Way:
git push origin my-feature
The gh
Way:
git push origin my-feature
gh pr create --fill --reviewer "team-member" --label "bug"
The --fill
flag automatically populates the PR title and description from your commit messages. The entire process takes seconds.
GitHub CLI is more than just a tool; it's a fundamental upgrade to a developer's toolkit. It respects the terminal-centric workflow that so many of us prefer and supercharges it with the collaborative power of GitHub. By reducing context switching and enabling powerful automation, gh
doesn't just save you clicks—it saves your focus.
If you haven't tried it yet, install it today. Run gh --help
and start exploring. You might just find that your browser's GitHub tab becomes a little less crowded.