How To Install gh on Ubuntu 22.04
Introduction
In this tutorial we learn how to install gh
on Ubuntu 22.04.
What is gh
gh is:
GitHub CLI “gh” is GitHub on the command line. It brings pull requests, issues, and other GitHub concepts to the terminal next to where you are already working with git and your code.
GitHub CLI is available for repositories hosted on GitHub.com and GitHub Enterprise Server 2.20+, and to install on macOS, Windows, and Linux.
Comparison with hub:
For many years, hub (https://github.com/github/hub) was the unofficial GitHub CLI tool. gh is a new project that helps us explore what an official GitHub CLI tool can look like with a fundamentally different design. While both tools bring GitHub to the terminal, hub behaves as a proxy to git, and gh is a standalone tool. Check out the more detailed explanation at https://github.com/cli/cli/blob/trunk/docs/gh-vs-hub.md to learn more.
There are three methods to install gh
on Ubuntu 22.04. We can use apt-get
, apt
and aptitude
. In the following sections we will describe each method. You can choose one of them.
Install gh Using apt-get
Update apt database with apt-get
using the following command.
sudo apt-get update
After updating apt database, We can install gh
using apt-get
by running the following command:
sudo apt-get -y install gh
Install gh Using apt
Update apt database with apt
using the following command.
sudo apt update
After updating apt database, We can install gh
using apt
by running the following command:
sudo apt -y install gh
Install gh Using aptitude
If you want to follow this method, you might need to install aptitude first since aptitude is usually not installed by default on Ubuntu. Update apt database with aptitude
using the following command.
sudo aptitude update
After updating apt database, We can install gh
using aptitude
by running the following command:
sudo aptitude -y install gh
How To Uninstall gh on Ubuntu 22.04
To uninstall only the gh
package we can use the following command:
sudo apt-get remove gh
Uninstall gh And Its Dependencies
To uninstall gh
and its dependencies that are no longer needed by Ubuntu 22.04, we can use the command below:
sudo apt-get -y autoremove gh
Remove gh Configurations and Data
To remove gh
configuration and data from Ubuntu 22.04 we can use the following command:
sudo apt-get -y purge gh
Remove gh configuration, data, and all of its dependencies
We can use the following command to remove gh
configurations, data and all of its dependencies, we can use the following command:
sudo apt-get -y autoremove --purge gh
References
Summary
In this tutorial we learn how to install gh
package on Ubuntu 22.04 using different package management tools: apt
, apt-get
and aptitude
.