The GitHub CLI brings pull requests, issues, Actions and releases to your terminal. In this lesson you will install gh, sign in, and use it for the daily tasks that otherwise need the browser, including checking out a developer’s PR to test it.
📖 What You’ll Learn: what gh is and how it differs from Git, installing and signing in, repository commands, creating, checking out, reviewing and merging pull requests, issues, GitHub Actions runs and artifacts, releases, and power features like gh api, aliases, secrets and extensions.
⌨️ What Is the GitHub CLI?
The GitHub CLI (gh) brings GitHub to your terminal. Git manages your repository; gh manages GitHub: repositories, pull requests, issues, Actions runs, releases and more, without opening the browser.
| Task | Git | GitHub CLI |
|---|---|---|
| Commit, branch, merge | ✅ | |
| Create a repository on GitHub | gh repo create | |
| Open and merge pull requests | gh pr create, gh pr merge | |
| Check CI runs and logs | gh run list, gh run view --log-failed | |
| Create issues and releases | gh issue create, gh release create |
📥 Install
| Platform | Command |
|---|---|
| Windows | winget install --id GitHub.cli |
| macOS | brew install gh |
| Ubuntu / Debian | Add GitHub’s official apt repository, then sudo apt install gh (see the install instructions on cli.github.com) |
| Fedora | sudo dnf install gh |
Check: gh --version.
🔐 Sign In
gh auth login
Choose GitHub.com, your preferred protocol (HTTPS or SSH) and Login with a web browser, then enter the one-time code shown in the terminal. gh can also configure Git to use it as a credential helper, so git push over HTTPS just works.
gh auth status # who am I and which scopes?
📁 Repositories
gh repo create my-tests --private --clone # new repo on GitHub and clone it
gh repo create --source=. --public --push # publish the current folder
gh repo clone acme/qa-platform
gh repo fork acme/qa-platform --clone # fork + clone + upstream remote
gh repo view --web # open the repo in the browser
See push an existing project and forks.
🔃 Pull Requests
gh pr create --title "Add login tests" --body "Closes #42" --reviewer ravi-kumar --label tests
gh pr create --fill --draft # title and body from your commits, as a draft
gh pr list # open PRs
gh pr status # PRs that involve you
gh pr checkout 57 # check out PR #57 locally to test it
gh pr diff 57
gh pr review 57 --approve # or --request-changes -b "Please add a test"
gh pr checks 57 # CI status
gh pr merge 57 --squash --delete-branch
💡 Tip: gh pr checkout <number> is the fastest way for a tester to run a developer’s change locally before it is merged (pull requests, code review).
🐞 Issues
gh issue create --title "Checkout total ignores discount" --label bug --assignee @me
gh issue list --label bug --state open
gh issue view 42 --comments
gh issue close 42 --comment "Fixed in #57"
⚙️ GitHub Actions
gh workflow list
gh workflow run ci.yml -f browser=firefox # trigger workflow_dispatch with an input
gh run list --limit 5
gh run watch # follow the latest run live
gh run view 123456789 --log-failed # only logs of failed steps
gh run download 123456789 -n playwright-report # download an artifact
gh run rerun 123456789 --failed # re-run failed jobs
These pair with workflow syntax and artifacts.
🏷️ Releases
gh release create v1.2.0 --generate-notes # release from a tag with auto notes
gh release create v1.2.0 ./dist/report.zip --title "v1.2.0"
gh release list
🧰 Power Features
gh api repos/acme/qa-platform/pulls --jq '.[].title' # call any REST endpoint, filter with jq
gh alias set prs 'pr list --author @me' # create shortcuts: gh prs
gh secret set TEST_PASSWORD # set an Actions secret (prompts for value)
gh variable set BASE_URL --body https://staging.example.com
gh extension install dlvhdr/gh-dash # extensions add new commands (here: a PR and issue dashboard)
Secrets and variables are explained in secrets and environments.
📝 Assignment
- Install
ghand log in withgh auth login. - Create a new private repository from the terminal with
gh repo create. - Create a branch, commit, and open a PR with
gh pr create --fill; check it withgh pr checksand merge it withgh pr merge --squash --delete-branch. - Create and close an issue from the terminal.
- Trigger a
workflow_dispatchworkflow withgh workflow runand follow it withgh run watch. - Create an alias for a command you use often.
❓ FAQ
🤔 What is GitHub CLI?
The official command-line tool gh for working with GitHub: repositories, pull requests, issues, Actions, releases and the API from your terminal.
🤔 How do I install GitHub CLI on Windows?
Run winget install --id GitHub.cli (or download the installer from cli.github.com), then gh auth login.
🤔 How do I create a pull request from the command line?
Push your branch and run gh pr create (add --fill to use your commit messages).
🤔 How do I check GitHub Actions logs from the terminal?
gh run list to find the run, then gh run view <id> --log-failed or gh run watch.
🤔 Is GitHub CLI the same as Git?
No. Git works with repositories and history; GitHub CLI works with GitHub features such as PRs, issues and Actions. You use them together.
🎯 Next Steps
🎬 Learn Git and GitHub step by step: watch the series on YouTube!
Subscribe to SqaToolsByDY • Practice on sqatools.in