GitHub CLI (`gh`) — Install, Authenticate, and Use from Your Terminal (2026)
GitHub CLI brings pull requests, issues, releases, and workflows straight to your terminal. Install in one command, authenticate once, and never open github.com again.
Jan 24, 2025·7 min read· Any platform beginner
Advertisement
GitHub CLI (gh) is GitHub’s official command-line tool. It brings pull requests, issues, releases, GitHub Actions, and repo management directly into your terminal — no more Alt-Tab to github.com.
You only do this once per machine. gh auth login walks you through it interactively:
Terminal — first-time auth
$gh auth login
? What account do you want to log into? GitHub.com
? What is your preferred protocol for Git operations? HTTPS
? Authenticate Git with your GitHub credentials? Yes
? How would you like to authenticate GitHub CLI? Login with a web browser
! First copy your one-time code: ABCD-1234
- Press Enter to open github.com in your browser...
Authentication complete.
- gh config set -h github.com git_protocol https
Configured git protocol
Logged in as your-username
Check who you’re logged in as
Terminal — verify auth
$gh auth status
github.com
Logged in to github.com account your-username (keyring)
- Active account: true
- Git operations protocol: https
- Token: gho_************************************
- Token scopes: 'gist', 'read:org', 'repo', 'workflow'
Repository management
The 5 commands you’ll use daily:
Terminal — repo commands
$gh repo create my-new-app --public --clone
Created repository your-username/my-new-app on GitHub
Cloned to /Users/you/my-new-app
$gh repo clone vercel/next.js
Cloning into 'next.js'...
$gh repo fork vercel/next.js --clone
Created fork your-username/next.js
Cloned fork
$gh repo view --web
Opening https://github.com/your-username/my-new-app in your browser.
Other useful repo commands:
gh repo list — your repos
gh repo list organization-name — org repos
gh repo edit --description "New description" — update repo metadata
gh pr create defaults to your current branch. Add --draft for draft PRs, --web to open the create form in browser instead.
View / open / merge
Terminal — gh pr lifecycle
$gh pr view
#421 Add empire-shells QuickAnswer
Open · your-username wants to merge 3 commits into main from feat/quick-answer
Checks passing
+ 142 -38 across 8 files
$gh pr view --web
Opening https://github.com/owner/repo/pull/421 in your browser.
$gh pr checkout 421
remote: Enumerating objects: 18, done.
Switched to branch 'feat/quick-answer'
$gh pr merge 421 --squash --delete-branch
Squashed and merged pull request #421
Deleted branch feat/quick-answer
Daily PR commands
Command
What it does
gh pr list
List open PRs in current repo
gh pr list --state all
Include closed/merged PRs
gh pr checkout <number>
Switch local branch to PR’s branch
gh pr review --approve
Approve current PR
gh pr review --request-changes -b "needs work"
Request changes with comment
gh pr diff
Show PR diff in terminal
gh pr status
PRs relevant to you (assigned, mentioned, reviewing)
Issues
Terminal — gh issue commands
$gh issue create --title "Bug in OSSettingsMockup window controls" --body "Window-control icons render as Unicode glyphs instead of SVG."
Created issue your-username/empire#142
$gh issue list --label bug --limit 5
#142 Bug in OSSettingsMockup window controls bug about 1 hour ago
#138 Callout icons should be SVG not Unicode bug about 4 hours ago
...
$gh issue close 142 --comment "Fixed in #421"
Closed issue #142
GitHub Actions workflows
Terminal — gh workflow + gh run
$gh workflow list
Deploy active 12345
Test active 12346
Lint active 12347
$gh workflow run Deploy
Created workflow run for "Deploy"
$gh run list --limit 3
X Deploy main push 2m45s abc1234
Test main push 1m22s abc1234
Lint main push 35s abc1234
$gh run watch
build (4m12s)
test (1m22s)
deploy (2m45s)
Run Deploy completed with success
Best practices
Authenticate once per machine — gh auth login stores credentials in your OS keychain
Default to HTTPS — easier than SSH for new setups, gh handles credential helpers automatically
Pin to a version in CI — install gh via apt/brew pinned to a known good version for reproducible builds
Use --web when you want browser — gh pr view --web, gh repo view --web, gh issue view --web
JSON output for scripts — every gh X view command supports --json field1,field2 for shell scripting
Conclusion
GitHub CLI cuts your context-switching overhead dramatically once installed. The 30-second install + 1-minute auth pays back the first time you gh pr create from your editor’s integrated terminal without breaking flow.