A newer version of the Gradio SDK is available:
6.2.0
Install and Authenticate GitHub CLI (gh)
You are helping the user install and authenticate the GitHub CLI tool.
Your tasks:
Check if gh is already installed:
which gh gh --versionIf already installed and authenticated:
gh auth statusInstall GitHub CLI (if not installed):
Method 1: Using official repository (recommended):
# Add the GPG key sudo mkdir -p -m 755 /etc/apt/keyrings wget -qO- https://cli.github.com/packages/githubcli-archive-keyring.gpg | sudo tee /etc/apt/keyrings/githubcli-archive-keyring.gpg > /dev/null sudo chmod go+r /etc/apt/keyrings/githubcli-archive-keyring.gpg # Add the repository echo "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/githubcli-archive-keyring.gpg] https://cli.github.com/packages stable main" | sudo tee /etc/apt/sources.list.d/github-cli.list > /dev/null # Install sudo apt update sudo apt install ghMethod 2: Using snap:
sudo snap install ghMethod 3: Using Homebrew (if installed):
brew install ghVerify installation:
gh --version which ghAuthenticate with GitHub:
Interactive authentication (recommended):
gh auth loginThis will prompt for:
- GitHub.com or GitHub Enterprise Server
- Preferred protocol (HTTPS or SSH)
- Authentication method (web browser or token)
Via web browser (easiest):
- Select "Login with a web browser"
- Follow the one-time code and URL
- Authorize in browser
Via token:
- Generate a token at https://github.com/settings/tokens
- Select "Login with authentication token"
- Paste the token
Verify authentication:
gh auth statusShould show:
- Logged in to github.com
- Account name
- Token scopes
Configure gh settings:
Set default editor:
gh config set editor vim # or gh config set editor nano # or gh config set editor code # VS CodeSet default protocol:
gh config set git_protocol ssh # or gh config set git_protocol httpsView all config:
gh config listSet up SSH key (if using SSH protocol):
# Generate SSH key if needed ssh-keygen -t ed25519 -C "your_email@example.com" # Add to ssh-agent eval "$(ssh-agent -s)" ssh-add ~/.ssh/id_ed25519 # Add to GitHub gh ssh-key add ~/.ssh/id_ed25519.pub --title "My Ubuntu Desktop" # Or copy public key to GitHub manually cat ~/.ssh/id_ed25519.pubTest GitHub connectivity:
# Test SSH connection ssh -T git@github.com # Test gh CLI gh repo list gh auth statusConfigure git to use gh for credentials:
gh auth setup-gitThis configures git to use gh as a credential helper.
Show basic gh commands:
Repository operations:
gh repo create- Create a repositorygh repo clone <repo>- Clone a repositorygh repo view- View repository detailsgh repo list- List your repositoriesgh repo fork- Fork a repository
Pull requests:
gh pr create- Create a pull requestgh pr list- List pull requestsgh pr view <number>- View a PRgh pr checkout <number>- Checkout a PRgh pr merge <number>- Merge a PRgh pr review <number>- Review a PR
Issues:
gh issue create- Create an issuegh issue list- List issuesgh issue view <number>- View an issuegh issue close <number>- Close an issue
Workflows:
gh workflow list- List workflowsgh workflow view <workflow>- View workflowgh workflow run <workflow>- Trigger a workflowgh run list- List workflow runsgh run view <run>- View a run
Gists:
gh gist create <file>- Create a gistgh gist list- List gistsgh gist view <gist>- View a gist
Set up shell completion:
For bash:
gh completion -s bash > ~/.gh-completion.bash echo 'source ~/.gh-completion.bash' >> ~/.bashrc source ~/.bashrcFor zsh:
gh completion -s zsh > ~/.gh-completion.zsh echo 'source ~/.gh-completion.zsh' >> ~/.zshrc source ~/.zshrcConfigure multiple accounts (if needed):
# Add another account GH_HOST=github.com gh auth login # Switch between accounts gh auth switchSet up aliases (optional):
gh alias set pv 'pr view' gh alias set co 'pr checkout' gh alias set bugs 'issue list --label=bug'List aliases:
gh alias listAuthenticate with GitHub Enterprise (if applicable):
gh auth login --hostname github.example.comTroubleshooting common issues:
Permission denied:
- Check auth status:
gh auth status - Re-authenticate:
gh auth login - Check token scopes
SSH issues:
- Verify SSH key:
ssh -T git@github.com - Add SSH key to GitHub:
gh ssh-key add - Check ssh-agent:
ssh-add -l
Rate limiting:
- Check rate limit:
gh api rate_limit - Use authentication to increase limits
- Check auth status:
Update gh:
sudo apt update sudo apt upgrade gh # or brew upgrade gh # or sudo snap refresh ghAdvanced configuration:
Custom API endpoint:
gh config set api_endpoint https://api.github.comDisable prompts:
gh config set prompt disabledConfigure pager:
gh config set pager lessSecurity best practices:
- Use SSH keys instead of HTTPS when possible
- Use tokens with minimal required scopes
- Rotate tokens regularly
- Don't share tokens
- Use different tokens for different machines
- Enable 2FA on GitHub account
- Review authorized applications regularly
Provide workflow examples:
Create a repo and push:
mkdir my-project cd my-project git init echo "# My Project" > README.md git add README.md git commit -m "Initial commit" gh repo create my-project --public --source=. --pushFork and clone:
gh repo fork owner/repo --cloneCreate PR from current branch:
gh pr create --title "My changes" --body "Description of changes"Report findings: Summarize:
- Installation status
- Authentication status
- Configured settings
- Available accounts
- Next steps
Important notes:
- gh is the official GitHub CLI
- Requires GitHub account
- Can use HTTPS or SSH protocol
- SSH is generally more secure and convenient
- gh can replace many git operations with simpler syntax
- Shell completion is very helpful
- Keep gh updated for latest features
- Multiple accounts are supported
- Works with both GitHub.com and GitHub Enterprise
- Tokens should have minimal required scopes