← Back to github/hub

How to Deploy & Use github/hub

Hub - GitHub CLI Tool

Prerequisites

  • Git 1.7.3 or newer - Hub wraps Git commands and requires a recent version
  • Go 1.11+ - Required if building from source
  • Command-line access - Hub is a terminal-based tool
  • GitHub account - Required for API interactions

Installation

Package Managers (Recommended)

macOS & Linux:

brew install hub

Windows (Scoop):

scoop install hub

Windows (Chocolatey):

choco install hub

Fedora Linux:

sudo dnf install hub

Arch Linux:

sudo pacman -S hub

Debian/Ubuntu:

sudo apt install hub

FreeBSD:

pkg install hub

openSUSE:

sudo zypper install hub

Void Linux:

sudo xbps-install -S hub

Gentoo:

sudo emerge dev-vcs/hub

Standalone Binary

Download the latest release for your system and place it in your executable path.

From Source

git clone \
  --config transfer.fsckobjects=false \
  --config receive.fsckobjects=false \
  --config fetch.fsckobjects=false \
  https://github.com/github/hub.git

cd hub
make install prefix=/usr/local

Configuration

Aliasing as Git

To make hub commands available as git commands:

eval "$(hub alias -s)"

Add this to your shell startup file (.bash_profile, .zshrc, etc.).

PowerShell:

Set-Alias git hub

GitHub Authentication

Hub uses Git's built-in credential helpers. Configure your GitHub credentials using:

git config --global credential.helper osxkeychain  # macOS
git config --global credential.helper manager      # Windows
git config --global credential.helper store         # Linux (stores in plaintext)

Environment Variables

  • GITHUB_TOKEN - Personal Access Token for API operations (optional, uses git credentials by default)
  • HUB_PROTOCOL - Set to ssh or https for clone operations

Build & Run

Development

  1. Clone the repository
  2. Install Go 1.11+
  3. Run tests:
    make test
    
  4. Build the binary:
    make
    

Running Commands

Basic usage examples:

# Clone a repository
hub clone rtomayko/tilt

# Create a pull request
hub pull-request -m "My changes"

# List open issues
hub issue

# Create an issue
hub issue create -m "Bug report"

Shell Tab Completion

Tab completion scripts are available in the etc/ directory for bash, zsh, and fish.

Deployment

Hub is a command-line tool designed for local development and CI/CD workflows. Recommended deployment scenarios:

GitHub Actions

steps:
- uses: actions/checkout@v2

- name: List open pull requests
  run: hub pr list
  env:
    GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

CI/CD Integration

Add hub to your CI pipeline:

# GitHub Actions
- name: Install hub
  run: brew install hub

# GitLab CI
before_script:
  - apk add --no-cache hub

Troubleshooting

Common Issues

1. "hub: command not found"

  • Ensure hub is in your PATH
  • Restart your terminal after installation
  • Verify with hub version

2. Authentication failures

  • Check your git credentials: git config --global --get credential.helper
  • Ensure your GitHub token has appropriate permissions
  • Test with: git ls-remote https://github.com/github/hub.git

3. Git version too old

git --version
# Ensure version is 1.7.3 or newer

4. Permission denied when installing

# For standalone install
chmod +x /path/to/hub
sudo mv /path/to/hub /usr/local/bin/hub

5. SSH clone issues

# Set SSH as default protocol
git config --global hub.protocol ssh

Debug Mode

Enable verbose output for troubleshooting:

hub -v <command>

API Rate Limiting

If you hit GitHub's API rate limits, create a Personal Access Token with repo scope and set it as GITHUB_TOKEN.