This skill helps manage GitHub repositories using GitHub CLI (gh). Includes basic operations like listing, creating, deleting, searching, and updating repo properties.
Check authentication before use:
gh auth status
If not logged in, run:
gh auth login
Below are basic and advanced commands for managing GitHub repositories.
List all repositories for a user:
gh repo list <username> --limit 100
List with JSON for easier parsing:
gh repo list <username> --limit 100 --json name,visibility,description,createdAt,updatedAt
Filter by visibility:
gh repo list <username> --visibility public
gh repo list <username> --visibility private
View detailed information of a repo:
gh repo view <owner>/<repo>
View details in JSON format:
gh repo view <owner>/<repo> --json name,description,visibility,defaultBranch,url,createdAt,updatedAt,pushedAt
Search repos by owner:
gh search repos --owner <username> --limit 20
Search by keyword:
gh search repos "<keyword>" --owner <username> --limit 20
WARNING: Permanent deletion, cannot be recovered!
gh repo delete <owner>/<repo> --confirm
Create new (empty) repo:
gh repo create <repo-name> --public
gh repo create <repo-name> --private
gh repo create <repo-name> --public --clone
Create repo from current directory (push code to GitHub):
gh repo create <repo-name> --source . --public
Rename repository (run in repo directory or specify owner/repo):
gh repo rename <new-name>
Switch between public and private:
gh repo edit <owner>/<repo> --visibility public
gh repo edit <owner>/<repo> --visibility private
Fork a repo to your account:
gh repo fork <owner>/<repo>
Archive repository (cannot push but can still clone):
gh repo edit <owner>/<repo> --archive
gh repo list dt418 --json name,visibility,description,createdAt
# Delete each repo
gh repo delete dt418/repo1 --confirm
gh repo delete dt418/repo2 --confirm
gh repo list dt418 --limit 100 --json name,createdAt,updatedAt | jq '.[] | select(.updatedAt < "2025-01-01")'
gh repo view dt418/repo-name --json isFork
By default gh CLI outputs to terminal. Use jq to parse:
# Get list of repo names
gh repo list dt418 --json name | jq '.[].name'
# Filter private repos
gh repo list dt418 --json name,visibility | jq '.[] | select(.visibility == "PRIVATE")'
# Count number of repos
gh repo list dt418 --json name | jq 'length'
# Get repo descriptions
gh repo list dt418 --json name,description | jq '.[] | select(.description != null)'
--confirm when deleting to avoid interactive promptsgh api to call GitHub API directly when advanced operations neededgh help <command> to see more optionsgh auth status before performing operations