ProgramGuru

Use GitHub CLI without leaving the terminal

Use GitHub CLI without leaving the terminal

Once Git commands feel natural, switching to a browser for every GitHub action can interrupt flow. GitHub CLI exposes many platform operations as gh commands.

What you’ll learn

  • Distinguish git from gh.
  • Inspect issues and PRs from the terminal.
  • Use GitHub CLI as a productivity tool.

Two CLIs, two layers

  1. git

    Manage local/distributed repository history.

    commit / branch / fetch
  2. gh

    Manage GitHub platform objects.

    PR / issue / release
  3. Together

    Use repository context to move smoothly between code and collaboration.

    developer workflow
developer workflow

git and gh are different command-line tools

git operates on Git repositories, commits, branches and remotes. gh communicates with GitHub for repository, issue, pull request, release and other platform operations.

Typical commands include gh auth login, gh repo view, gh issue list, gh pr status and gh pr create. Use gh help and subcommand help instead of memorizing everything.

Inspect GitHub state from the project directory

Run this in a disposable practice repository unless the lesson explicitly says otherwise.

gh auth status
gh repo view
gh issue list
gh pr status
gh pr view --web

gh can often infer the current GitHub repository from your configured Git remote. Authentication and permissions still determine which operations are allowed.

Practice: GitHub CLI

Your task: Create a disposable issue with gh issue create, list it, then open it in the browser with the appropriate gh command.

Common pitfall to avoid

CLI convenience does not remove the need to inspect what an action will change. Read command help, especially for destructive or organization-wide operations.

Check your understanding

Which tool would you normally use to open a GitHub pull request from the terminal?
Choose one answer. You can try again.

Answer and explanation

gh

Correct. Pull requests are GitHub platform objects.

GitHub CLI: what to remember

Use GitHub CLI without leaving the terminal is complete when you can explain the state being changed before you run the command, not merely repeat the syntax.

Read further: official supporting documentation.

Reaching the recap and completing the quizzes are separate milestones.

    Next lesson: Capstone: collaborate as a four-developer team →