GitHub CLI: The Complete Guide to Using GitHub from Your Terminal
In modern software development, we spend a lot of time on GitHub: creating repositories, managing pull requests, reviewing code, handling issues…
But what if you could do all of that without opening your browser?
In this article, we’ll explore GitHub CLI, the official tool that lets you interact with GitHub directly from your terminal.
🚀 What is GitHub CLI?
GitHub CLI (command: gh) is GitHub’s official command-line tool.
It allows you to:
- Create and manage repositories
- Open and manage Pull Requests
- Create and assign Issues
- Trigger GitHub Actions workflows
- Automate development tasks
👉 In short: you control GitHub without leaving your terminal.
💻 Installation
Windows
winget install --id GitHub.clilinux
The command can depend on your linux distribution
sudo apt install gh🔐 Authentication
Once installed, run:
gh auth loginYou’ll be guided to:
-
Choose GitHub.com or GitHub Enterprise
-
Authenticate via browser or token
-
Select your preferred protocol (HTTPS or SSH)
After this step, your terminal is connected to your GitHub account.
📁 Essential Commands
1️⃣ Create a Repository
gh repo create my-projectUseful options:
gh repo create my-project --public --source=. --remote=origin --pushThis will:
-
Create the repository on GitHub
-
Link it to your local folder
-
Automatically push your code
2️⃣ Clone a Repository
gh repo clone username/repository3️⃣ Create a Pull Request
gh pr createThe interactive assistant will ask for:
- The base branch
- The title
- The description
You can also automate it:
gh pr create --title "New Feature" --body "Adds the new feature implementation"4️⃣ List Pull Requests
gh pr list5️⃣ Create an Issue
gh issue createYou can also specify details directly:
gh issue create --title "Bug in login flow" --body "Error occurs when submitting the form"🔄 Practical Workflow Example
Here’s a simple real-world workflow using GitHub CLI:
-
Initialize your local project
-
Create a repository:
gh repo create my-app --public --source=. --push-
Create a new branch and implement a feature
-
Push your branch:
git push origin feature-branch- Open a Pull Request:
gh pr create- Merge the PR:
gh pr mergeAll without opening GitHub in your browser.