GitHub from the command line with hub
Get Quicker
The handy hub command-line tool lets you manage your GitHub repository from a terminal window, which can make it easier to automate repetitive tasks.
Hub is an extension to command-line Git that allows you to perform everyday GitHub tasks straight from the terminal. The hub [1] extension forms an important part of the standard toolset for working with GitHub, alongside tools like Prose [2], a text editor, and coding platforms like Atom [3].
There are several huge advantages to using hub. First and foremost, it saves you time by letting you clone or create GitHub private repositories from your command line. Because hub also makes use of the power inherent in the command line, you can also use it to automate repetitive tasks.
This article describes the benefits of hub. I'll give you an example of what hub can do, and then I'll take you through the basics of using it.
Advantages of hub
First, let's give credit where credit is due. The GUI that is used by GitHub is not a bad system. It allows beginners to start using GitHub easily, and even for advanced users, it offers a good selection of automated tools and an intuitive way to complete most common tasks.
There are times, however, when you just need a command line – either because you are simply more comfortable working from the command line or because your repos have grown in complexity and number, and you want a way of automating your workflow. Hub provides these benefits, allowing you to do anything you can with a command-line interface – from wildcards to scripting – and giving you all of this functionality in GitHub.
For users who are accustomed to working at the command line, hub is simply faster than working with the GitHub GUI – at least for complicated projects. But keep in mind that hub is intended for advanced users. If you're new to GitHub, it is a good idea to become familiar with the GitHub basics before jumping into hub.
Before You Begin
Hub integrates directly with your GitHub account, so it poses a potential security risk. This risk is relatively low, and most developers who wish to use hub will know how to mitigate it. But in the interest of due diligence, I'll point out that the standard advice applies: Make sure you encrypt the connection between your terminal and GitHub's servers, and incorporate GitHub into your password manager.
Installation
The first step in installing hub is to make sure that you've got the correct version of Git. At the command line, run the following command:
$ git --version
This command will return your Git version. In order to use hub, the version must be 1.7.3 or newer. If Git is missing, or if you have an older version, don't worry: You can easily install a new version. One of the most popular (and, to my mind, the best) ways to install it is to use Homebrew [4], an open-source package manager, but you can also use the package manager that ships with your OS.
To install brew
, the command-line utility for Homebrew, enter the following command:
$ /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)"
This command will install to ~/.linuxbrew
, but you can sudo
the command if you want to change this.
Now you can install hub using brew
:
$ brew install hub
You can then do a sanity check by looking for the version of hub you have installed:
$ hub version git version 2.25.0 hub version 2.14.1 #
Buy this article as PDF
(incl. VAT)
Buy Linux Magazine
Subscribe to our Linux Newsletters
Find Linux and Open Source Jobs
Subscribe to our ADMIN Newsletters
Support Our Work
Linux Magazine content is made possible with support from readers like you. Please consider contributing when you’ve found an article to be beneficial.
News
-
Juno Tab 3 Launches with Ubuntu 24.04
Anyone looking for a full-blown Linux tablet need look no further. Juno has released the Tab 3.
-
New KDE Slimbook Plasma Available for Preorder
Powered by an AMD Ryzen CPU, the latest KDE Slimbook laptop is powerful enough for local AI tasks.
-
Rhino Linux Announces Latest "Quick Update"
If you prefer your Linux distribution to be of the rolling type, Rhino Linux delivers a beautiful and reliable experience.
-
Plasma Desktop Will Soon Ask for Donations
The next iteration of Plasma has reached the soft feature freeze for the 6.2 version and includes a feature that could be divisive.
-
Linux Market Share Hits New High
For the first time, the Linux market share has reached a new high for desktops, and the trend looks like it will continue.
-
LibreOffice 24.8 Delivers New Features
LibreOffice is often considered the de facto standard office suite for the Linux operating system.
-
Deepin 23 Offers Wayland Support and New AI Tool
Deepin has been considered one of the most beautiful desktop operating systems for a long time and the arrival of version 23 has bolstered that reputation.
-
CachyOS Adds Support for System76's COSMIC Desktop
The August 2024 release of CachyOS includes support for the COSMIC desktop as well as some important bits for video.
-
Linux Foundation Adopts OMI to Foster Ethical LLMs
The Open Model Initiative hopes to create community LLMs that rival proprietary models but avoid restrictive licensing that limits usage.
-
Ubuntu 24.10 to Include the Latest Linux Kernel
Ubuntu users have grown accustomed to their favorite distribution shipping with a kernel that's not quite as up-to-date as other distros but that changes with 24.10.