GitHub CLI brings GitHub functionality directly to your terminal. Instead of switching between the command line and browser, you can manage repositories, pull requests, issues, and workflows from a single interface. Whether you need to quickly clone a repository, review pending pull requests, or trigger CI/CD pipelines, GitHub CLI streamlines these tasks into simple commands. By the end of this guide, you will have GitHub CLI installed and authenticated on Rocky Linux, ready to interact with your GitHub repositories.
GitHub CLI installs identically on Rocky Linux 8, 9, and 10 using the official GitHub repository. The commands and configuration steps remain consistent across all three versions.
Update Your System
Before installing GitHub CLI, update your Rocky Linux system to ensure all packages and security patches are current:
sudo dnf upgrade --refresh
Rocky Linux 10 - BaseOS 3.3 MB/s | 6.4 MB 00:01 Rocky Linux 10 - AppStream 1.2 MB/s | 2.1 MB 00:01 Rocky Linux 10 - Extras 5.3 kB/s | 5.9 kB 00:01 Dependencies resolved.
This command refreshes the repository metadata and upgrades all installed packages. The exact repo names and versions vary by release, and the process may take a few minutes.
Add GitHub CLI Repository
Rocky Linux does not ship GitHub CLI in the default repositories, so you will add GitHub’s official RPM repository for current releases. First, ensure the DNF config-manager plugin is available:
sudo dnf install 'dnf-command(config-manager)' -y
The -y flag automatically confirms the prompt; remove it if you want to review the package list first.
If the plugin is already installed, DNF will report that there is nothing to do. Next, add the official GitHub CLI repository to your system:
sudo dnf config-manager --add-repo https://cli.github.com/packages/rpm/gh-cli.repo
You should see confirmation that the repository was added:
Adding repo from: https://cli.github.com/packages/rpm/gh-cli.repo
This repository provides pre-built GitHub CLI packages that receive updates directly from the GitHub team.
Install GitHub CLI
GitHub CLI depends on Git for version control operations. If you are new to Git, follow the Install Git on Rocky Linux guide to install Git from the base repositories and verify it, or install it directly:
sudo dnf install git -y
Next, install GitHub CLI from the official repository:
sudo dnf install gh --repo gh-cli -y
The --repo gh-cli flag ensures DNF pulls GitHub CLI from the official GitHub repository instead of any other enabled repo.
During installation, DNF imports the GitHub CLI GPG signing key automatically. You will see output similar to the following:
Importing GPG key 0x75716059: Userid : "GitHub CLI <opensource+cli@github.com>" Fingerprint: 2C61 0620 1985 B60E 6C7A C873 23F3 D4EA 7571 6059 From : https://keyserver.ubuntu.com/pks/lookup?op=get&search=0x23F3D4EA75716059 Key imported successfully
This GPG key ensures that packages from the GitHub repository are authentic and have not been tampered with.
Verify Installation
After installation completes, verify that GitHub CLI is working correctly by checking the version:
gh --version
You should see output confirming the installed version:
gh version 2.83.2 (2025-12-10) https://github.com/cli/cli/releases/tag/v2.83.2
This output confirms GitHub CLI is installed and accessible from your terminal. Your version number may differ, as GitHub releases updates regularly.
Authenticate with GitHub
Before using GitHub CLI to interact with repositories, you must authenticate with your GitHub account. Start the interactive login process:
gh auth login
The CLI guides you through several authentication choices:
? What account do you want to log into? GitHub.com ? What is your preferred protocol for Git operations on this host? HTTPS ? Authenticate Git with your GitHub credentials? Yes ? How would you like to authenticate GitHub CLI? Login with a web browser
When prompted for a protocol, choose HTTPS if you want simpler credential management through the CLI, or SSH if you already have SSH keys configured and prefer that workflow. Answering “Yes” to authenticate Git with your GitHub credentials configures the CLI as a Git credential helper, so you will not need to enter credentials for each Git operation. This choice can also request the workflow scope so pushes that modify workflow files succeed.
When you select browser authentication, the CLI displays a one-time code. Open the provided URL in your browser and enter the code to complete authentication. If you work on a headless server or prefer not to use browser-based login, choose the personal access token option instead.
GitHub Enterprise Users
If you use GitHub Enterprise Server instead of github.com, select “GitHub Enterprise Server” when prompted for the account type. You will need to provide your enterprise hostname:
gh auth login -h github.example.com
Replace github.example.com with your organization’s GitHub Enterprise hostname. The authentication flow works the same way as github.com once you specify the correct host.
Verify Authentication Status
After completing authentication, confirm your login status:
gh auth status
Successful authentication displays your account details:
github.com ✓ Logged in to github.com account monalisa (GH_CONFIG_DIR/hosts.yml) - Active account: true - Git operations protocol: https - Token: gho_****** - Token scopes: 'repo', 'read:org'
Common GitHub CLI Commands
With authentication complete, GitHub CLI is ready for everyday use. The following examples demonstrate common operations:
Clone a Repository
Clone a repository using the owner and repository name format:
gh repo clone owner/repository
For example, to clone the GitHub CLI repository itself:
gh repo clone cli/cli
Create a Pull Request
From within a repository with committed changes, create a pull request interactively:
gh pr create
The CLI prompts for a title, body, and target branch. Add the --web flag to complete the pull request in your browser instead.
List Issues
View open issues in the current repository:
gh issue list
Filter by labels, assignees, or state using additional flags. For example, to see only issues assigned to you:
gh issue list --assignee @me
Trigger a Workflow
Run a GitHub Actions workflow directly from the terminal:
gh workflow run workflow-name.yml
The workflow file must include an on: workflow_dispatch trigger or GitHub will reject the run request.
This command is useful for triggering CI/CD pipelines without navigating to the GitHub web interface.
Create a Repository from Local Code
One of the most practical uses of GitHub CLI is creating a new repository directly from an existing project folder. Navigate to your project directory and run:
cd ~/my-project
gh repo create
The CLI prompts you to choose between pushing an existing local repository or creating a new one. If you select “Push an existing local repository to GitHub”, it creates the remote repository and configures your local Git remotes automatically. This workflow replaces the traditional process of creating a repository on GitHub’s website, copying the remote URL, and manually adding it with git remote add.
For a complete list of available commands, visit the GitHub CLI command reference. The GitHub CLI repository contains additional documentation, and the releases page shows version history and changelogs.
Update GitHub CLI
Since GitHub CLI is installed from a DNF repository, updates arrive through the standard package manager. To update to the latest version:
sudo dnf update gh --repo gh-cli
The --repo gh-cli flag ensures the update comes from the official GitHub repository. Alternatively, running sudo dnf upgrade --refresh updates all packages on your system, including GitHub CLI.
Troubleshooting
Git Dependency Missing
If installation fails with a Git dependency error, you may see:
Error: Problem: cannot install the best candidate for the job - nothing provides git needed by gh-2.83.2-1.x86_64 from gh-cli
This happens when Git is not installed or the AppStream repository is unavailable, so DNF cannot satisfy the dependency.
Check whether Git is installed:
rpm -q git
package git is not installed
Install Git first, then install GitHub CLI from the official repository:
sudo dnf install git -y
sudo dnf install gh --repo gh-cli -y
Verify that both tools are available:
command -v git
gh --version
/usr/bin/git gh version 2.83.2 (2025-12-10) https://github.com/cli/cli/releases/tag/v2.83.2
Authentication Fails
If gh reports that you are not logged in after running gh auth login, check your current status:
gh auth status
You are not logged into any GitHub hosts. To log in, run: gh auth login
This means GitHub CLI has no stored credentials for the host you are targeting.
Start an interactive login:
gh auth login
For headless systems, create a classic personal access token with the required scopes repo, read:org, and gist, then authenticate from a file:
gh auth login --with-token < mytoken.txt
For fine-grained personal access tokens, set the GH_TOKEN environment variable instead:
export GH_TOKEN=your_personal_access_token
Re-run the status check and confirm your account appears:
gh auth status
github.com ✓ Logged in to github.com account monalisa (GH_CONFIG_DIR/hosts.yml) - Active account: true - Git operations protocol: https - Token: gho_****** - Token scopes: 'repo', 'read:org'
If you chose to authenticate Git with your credentials, the token scopes list may also include workflow.
Remove GitHub CLI
If you no longer need GitHub CLI, you can remove the package and optionally clean up the repository and local configuration.
Remove the Package
Start by removing the GitHub CLI package:
sudo dnf remove gh
DNF removes unused dependencies by default. If you want to keep them, add --noautoremove to the command.
Remove the Repository (Optional)
If you also want to remove the GitHub CLI repository from your system:
sudo rm /etc/yum.repos.d/gh-cli.repo
After removing the repository file, refresh the DNF cache:
sudo dnf clean all
Remove User Configuration (Optional)
GitHub CLI stores configuration and authentication data under ~/.config/gh. Remove it only if you no longer need saved hosts or tokens.
The following command permanently deletes GitHub CLI configuration files in
~/.config/gh. Back up the folder first if you want to keep saved hosts or tokens.
rm -rf ~/.config/gh
Verify Removal
Confirm that GitHub CLI is no longer available:
gh --version
If removal succeeded, you will see:
bash: gh: command not found
Conclusion
You now have GitHub CLI installed on Rocky Linux using the official GitHub repository. With authentication configured, you can clone repositories, manage pull requests and issues, trigger workflows, and perform other GitHub operations directly from your terminal. The CLI integrates with your existing Git workflow and receives automatic updates through DNF, keeping your tooling current with the latest GitHub features.