Developers : 9-Set Up the GitHub CLI
How to Set Up the GitHub CLI in Under 3 Minutes
GitHub is an essential tool for developers, and with the GitHub Command Line Interface (CLI), you can streamline your workflows right from the terminal. In this tutorial, we’ll guide you through the steps to set up the GitHub CLI quickly and efficiently. Whether you’re a seasoned developer or just starting, this guide will help you make the most of your GitHub experience.
What is GitHub CLI?
The GitHub CLI is a command-line tool that allows you to manage GitHub resources directly from the terminal. It provides a user-friendly interface for common GitHub tasks such as creating repositories, managing issues, and handling pull requests—all without needing to leave your command line.
Prerequisites
Before we begin, ensure you have the following:
- A GitHub account: If you don’t have one, you can sign up here.
- A terminal or command prompt: This can be on Linux, macOS, or Windows.
- Git installed: The Git CLI should already be installed on your machine. You can download it from git-scm.com.
Step 1: Install GitHub CLI
The first step is to install the GitHub CLI. Depending on your operating system, the installation process varies.
For macOS
You can use Homebrew to install GitHub CLI. Open your terminal and run:
brew install gh
For Windows
On Windows, you can use the Windows Package Manager (winget) or download the installer directly from the GitHub CLI release page.
Using winget:
winget install GitHub.cli
For Linux
For Linux distributions, you can use the package manager specific to your distribution. For example, on Ubuntu, you can run:
sudo apt install gh
For other distributions, refer to the GitHub CLI installation documentation.
Step 2: Authenticate GitHub CLI
Once you’ve installed the GitHub CLI, the next step is to authenticate it with your GitHub account. Open your terminal and run:
gh auth login
This command will prompt you to choose a preferred authentication method. You can select either HTTPS or SSH. Follow the on-screen instructions to log in.
- Select the preferred protocol: Choose either
HTTPSorSSH. - Authenticate: If you choose HTTPS, you will be asked to enter your GitHub username and password. If you have two-factor authentication enabled, you will also need to provide a code.
- Complete the login: If you choose SSH, you will need to add your SSH key to your GitHub account. Follow the instructions provided by the CLI to generate and add your SSH key.
Step 3: Verify Installation
After authenticating, it’s a good idea to verify that the GitHub CLI is set up correctly. You can do this by running:
gh --version
This command should display the installed version of GitHub CLI, confirming that the setup was successful.
Step 4: Explore GitHub CLI Commands
Now that you have the GitHub CLI set up, you can start using it to manage your GitHub repositories. Here are a few commands to get you started:
Create a new repository:
gh repo create <repository-name>Clone a repository:
gh repo clone <repository-url>View issues:
gh issue listCreate a pull request:
gh pr create --base <branch-name> --head <branch-name>
Conclusion
Setting up the GitHub CLI is a straightforward process that can significantly enhance your productivity as a developer. With just a few commands, you can manage your GitHub projects directly from your terminal, making it a powerful addition to your development toolkit.
Feel free to explore additional commands and functionalities by checking the GitHub CLI documentation. Happy coding!
Connect with SkillBakery Studios
Explore more tutorials, tools, and resources:
Posted by SkillBakery Studios


No comments:
Post a Comment