Learn the Basics of GitHub CLI

Hi ๐ Iโm Abhinav Prakash - a full-stack dev who loves building with Node.js, React, Next, Astro, MongoDB & Cloud. I share my blogs, learnings, side-projects, and dev journey here ๐
1. Installation
Windows
Download installer from the GitHub CLI releases
Or install via Scoop:
scoop install gh
- Or via Chocolatey:
choco install gh
macOS
- Install via Homebrew:
brew install gh
Linux
- Debian/Ubuntu:
sudo apt install gh
- Fedora:
sudo dnf install gh
- Arch Linux:
sudo pacman -S github-cli
2. Authenticate with GitHub
Run:
gh auth login
Select GitHub.com or GitHub Enterprise.
Choose HTTPS or SSH as preferred.
Use a personal access token or OAuth for authentication.
Verify authentication:
gh auth status
3. Basic Commands
- Version Check:
gh --version
- Configure Editor:
gh config set editor "vim"
4. Working with Repositories
- Create a New Repository:
gh repo create my-new-repo --public
- Clone a Repository:
gh repo clone /
- View Repository Details:
gh repo view my-repo --web
5. Managing Issues
- List Issues:
gh issue list
- Create a New Issue:
gh issue create --title "Bug in login system" --body "User cannot log in with valid credentials."
- View Issue Details:
gh issue view
6. Managing Pull Requests (PRs)
- List Pull Requests:
gh pr list
- Create a New PR:
gh pr create --title "Fix memory leak" --body "This PR fixes the memory leak in X module."
- View PR Details:
gh pr view
- Merge a PR:
gh pr merge --merge
7. Managing Gists
- Create a New Gist:
gh gist create file.txt --public
- List Gists:
gh gist list
- View a Gist:
gh gist view
8. GitHub Actions and Workflows
- List Workflow Runs:
gh run list
- View a Specific Workflow Run:
gh run view
- Trigger a Workflow:
gh workflow run
9. GitHub CLI Aliases
- Create an Alias:
gh alias set myrepos 'repo list --limit 10'
10. Logging Out
- Log Out:
gh auth logout





