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
-
Latest Cinnamon Desktop Releases with a Bold New Look
Just in time for the holidays, the developer of the Cinnamon desktop has shipped a new release to help spice up your eggnog with new features and a new look.
-
Armbian 24.11 Released with Expanded Hardware Support
If you've been waiting for Armbian to support OrangePi 5 Max and Radxa ROCK 5B+, the wait is over.
-
SUSE Renames Several Products for Better Name Recognition
SUSE has been a very powerful player in the European market, but it knows it must branch out to gain serious traction. Will a name change do the trick?
-
ESET Discovers New Linux Malware
WolfsBane is an all-in-one malware that has hit the Linux operating system and includes a dropper, a launcher, and a backdoor.
-
New Linux Kernel Patch Allows Forcing a CPU Mitigation
Even when CPU mitigations can consume precious CPU cycles, it might not be a bad idea to allow users to enable them, even if your machine isn't vulnerable.
-
Red Hat Enterprise Linux 9.5 Released
Notify your friends, loved ones, and colleagues that the latest version of RHEL is available with plenty of enhancements.
-
Linux Sees Massive Performance Increase from a Single Line of Code
With one line of code, Intel was able to increase the performance of the Linux kernel by 4,000 percent.
-
Fedora KDE Approved as an Official Spin
If you prefer the Plasma desktop environment and the Fedora distribution, you're in luck because there's now an official spin that is listed on the same level as the Fedora Workstation edition.
-
New Steam Client Ups the Ante for Linux
The latest release from Steam has some pretty cool tricks up its sleeve.
-
Gnome OS Transitioning Toward a General-Purpose Distro
If you're looking for the perfectly vanilla take on the Gnome desktop, Gnome OS might be for you.