Skip to content
💻 🧠 Code 1001 > 📚 Learning Materials > Git > GitHub > What is GitHub CLI?

What is GitHub CLI?

CLI is convenient for developers, DevOps engineers, and anyone who automates work with GitHub or prefers the terminal over a browser.


Installation

GitHub CLI is supported on WindowsmacOS, and Linux.

  • Linux (Ubuntu/Debian):
sudo apt install gh
  • macOS (via Homebrew):
brew install gh
  • Windows (via Winget):
winget install --id GitHub.cli

After installation, check the version:

gh --version

Authorization

To access private repositories and actions, you need to authorize:

gh auth login

CLI will prompt you to:

  • choose GitHub.com or GitHub Enterprise
  • authorization method (browser, token, SSH)
  • save data for subsequent launches

You can check the status with the command:

gh auth status

Main features

Working with repositories

Creating a new repository:

gh repo create my-project

Cloning:

gh repo clone owner/repo

Viewing information:

gh repo view owner/repo

Issues

Creating an issue:

gh issue create --title "Bug: crash on startup" --body "Steps to reproduce..."

List of issues:

gh issue list

Viewing a specific issue:

gh issue view 42

Pull Requests

Creating a pull request:

gh pr create --base main --head feature-branch --title "New feature" --body "Added new functionality"

Viewing:

gh pr list
gh pr view 123

Merging:

gh pr merge 123 --squash --delete-branch

Actions (CI/CD)

Running workflows:

gh workflow run build.yml

Viewing status:

gh run list

Useful commands

CommandPurpose
gh helplist all commands
gh alias set co "pr checkout"create an alias for a quick command
gh gist create file.txtupload file as gist
gh release create v1.0.0create release

Advantages of GitHub CLI

  • Time saving: work with GitHub without a browser.
  • Scripting: convenient to automate in bash/PowerShell.
  • CI/CD integration.
  • Single tool for commands and GitHub API.

Great 🚀 Then let’s make a checklist “TOP-10 GitHub CLI commands for daily use”. It can be used as a cheat sheet.


✅ TOP-10 GitHub CLI commands for daily use

1. Authorization

gh auth login

🔑 Authorize to GitHub via browser or token. Useful for first-time setup or account changes.


2. Check authorization status

gh auth status

📌 Checks if the CLI is connected to GitHub and how.


3. Clone repository

gh repo clone owner/repo

📥 Quick cloning of a repository without searching for a link in the web interface.


4. Create a new repository

gh repo create my-project

🆕 Create a repository directly from the terminal (locally + on GitHub).


5. View repository information

gh repo view --web

📖 Shows repository description and settings. The --web option immediately opens the page in the browser.


6. List issues

gh issue list

📋 Convenient for viewing tasks and bugs directly in the terminal.


7. Create an issue

gh issue create --title "Bug: login failed" --body "Steps to reproduce..."

🐞 Creates a new task or bug report.


8. Create Pull Request

gh pr create --base main --head feature-branch --title "New feature" --body "Description..."

🔀 Main tool for teamwork: opening a Pull Request from your branch.


9. View and check PR

gh pr view 123

👀 View Pull Request with comments and check statuses. You can add --web to open in browser.


10. Merge PR with branch deletion

gh pr merge 123 --squash --delete-branch

✅ Merge Pull Request + delete branch in one step.


📌 GitHub CLI — Cheat Sheet

🔑 Authorization and settings

КомандаPurpose
gh auth loginAuthorization (browser, token, SSH)
gh auth statusCheck current connection
gh alias set co "pr checkout"Create alias for command
gh config getGet CLI settings

📂 Repositories

CommandPurpose
gh repo createCreate repository
gh repo cloneClone repository
gh repo viewRepo info (or open in web)
gh repo forkFork repository

📝 Issues

CommandPurpose
gh issue listList tasks
gh issue createCreate issue
gh issue viewView issue
gh issue closeClose issue

🔀 Pull Requests

CommandPurpose
gh pr listList PRs
gh pr createCreate PR
gh pr viewView PR
gh pr checkoutSwitch to PR branch
gh pr mergeMerge PR

📦 Releases

CommandPurpose
gh release listList releases
gh release createCreate release
gh release uploadAdd file to release
gh release viewView release

📜 Gists

CommandPurpose
gh gist createCreate gist
gh gist listList gists
gh gist viewView gist
gh gist editEdit gist

⚙️ Workflows (GitHub Actions)

CommandPurpose
gh workflow listList workflows
gh workflow viewView workflow
gh workflow runRun workflow
gh run listList runs
gh run watchWatch run

Leave a Reply

Your email address will not be published. Required fields are marked *