← Back to list

Master GitHub from Your Terminal: A Hands-On Guide to the GitHub CLI (gh)

If you’re a developer, you likely interact with GitHub every single day. You’re reviewing pull requests, managing repositories, or…

Aman Ghatiya · 2025-07-24 11:21 · 0 claps · 2.8 min read
#github #github-cli #git
Open on Medium ↗
Wiki topics: 🔓 · Open Source

Master GitHub from Your Terminal: A Hands-On Guide to the GitHub CLI (gh)

If you’re a developer, you likely interact with GitHub every single day. You’re reviewing pull requests, managing repositories, or triggering workflows. While the GitHub web interface is undoubtedly powerful, what if I told you that you could accomplish almost all of these tasks directly from your terminal? That’s where the GitHub CLI (gh) comes in—a powerful tool designed to supercharge your workflow and keep you laser-focused.

In this hands-on guide, you’ll discover how to leverage the most useful gh commands to effortlessly handle repositories, authentication, pull requests, and even GitHub Actions, all without ever leaving your command line. We'll also clarify how gh seamlessly works alongside traditional git commands for pushing and pulling your code.

Getting Started: Check Your Installation

First things first, let’s make sure you have the GitHub CLI installed. To verify your installation and see which version you’re running, simply use:

gh --version

If you haven’t installed it yet, no worries! Just head over to cli.github.com for straightforward setup instructions.

Authentication: Connect Your GitHub Account

Before you can start interacting with your repositories, you’ll need to authenticate with GitHub.

Check your current authentication status:

gh auth status

To log in to GitHub:

gh auth login

This command will launch an interactive prompt to guide you through a secure login process.

Working with Repositories

The gh CLI makes repository management a breeze.

Clone a repository:

gh repo clone <owner>/<repository>

This command quickly clones the specified repository to your local machine.

View repository details (including the README):

gh repo view

Run this command inside a cloned repository to instantly see its description, README content, and more — all right there in your terminal!

Pull Requests: Stay on Top of Your Code Reviews

Managing pull requests becomes effortless with gh.

List all pull requests:

gh pr list

This command quickly displays all open pull requests for your current repository, saving you countless clicks and page loads.

GitHub Actions: Managing CI/CD from the Terminal

Take control of your CI/CD pipelines directly from your terminal.

List available workflows:

gh workflow list

View details of a specific workflow:

gh workflow view <workflow-id>

Replace <workflow-id> with the actual workflow number or name.

Manually trigger a workflow

gh workflow run <workflow-file> <ref>

Example:

gh workflow run ci.yml main

Here, ci.yml refers to your workflow file, and main is the branch or commit reference.

Monitoring Workflow Runs

Keep a close eye on your GitHub Actions runs without leaving your terminal.

List workflow runs for a specific workflow:

gh run list --workflow="ci.yml"

View a specific workflow run:

gh run view <run-id>

Rerun an entire workflow job:

gh run rerun <run-id>

Rerun only failed jobs in a workflow run:

gh run rerun --failed <run-id>

View a specific job in a workflow run:

gh run view --job=<job-id>

See logs for a particular job:

gh run view --log --job=<job-id>

Push and Pull: Don’t Forget git!

While the GitHub CLI is incredibly powerful, it’s crucial to remember that pushing and pulling code — the core version control operations — are still handled by the standard git commands, not gh.

The GitHub CLI is designed to complement git, not replace it. Use git for your source code operations, and gh for GitHub-specific features and interactions.

Why Use the GitHub CLI?

The benefits of integrating gh into your workflow are clear:

  • Speed: No need to leave your terminal or context-switch to a browser. Stay in your flow!
  • Automation: Script your routine GitHub tasks for even greater efficiency and consistency.
  • Consistency: The same commands work flawlessly across various operating systems and development environments.

Final Thoughts

The GitHub CLI (gh) is truly a must-have tool for any developer who values the efficiency and power of the command line. From effortlessly cloning repositories and managing pull requests to automating and monitoring your workflows, gh puts the full power of GitHub just a few keystrokes away.

Remember this key distinction:

  • Use git for pushing and pulling code (your core version control operations).
  • Use gh to interact with GitHub features and significantly streamline your workflow.

Ready to level up your workflow and spend less time context-switching? Check out the official GitHub CLI documentation and start mastering GitHub from your terminal today!

Do you have your own favorite gh tips or tricks? Share them in the comments below and let's learn from each other!


메타데이터
post_id
1bf7cd32d0ee
slug
master-github-from-your-terminal-a-hands-on-guide-to-the-github-cli-gh-1bf7cd32d0ee
url
https://medium.com/@amanghatiya/master-github-from-your-terminal-a-hands-on-guide-to-the-github-cli-gh-1bf7cd32d0ee
canonical_url
https://medium.com/@amanghatiya/master-github-from-your-terminal-a-hands-on-guide-to-the-github-cli-gh-1bf7cd32d0ee
author_url
https://medium.com/@amanghatiya
status
ok
fetched_at
2026-06-15 20:49:13