LinuxCommandLibrary

hub

Interact with GitHub from the command line

TLDR

Clone a repository using its slug (owners can omit the username)

$ hub clone [username]/[repo_name]
copy

Create a fork of the current repository (cloned from another user) under your GitHub profile
$ hub fork
copy

Push the current local branch to GitHub and create a PR for it in the original repository
$ hub push [remote_name] && hub pull-request
copy

Create a PR of the current (already pushed) branch, reusing the message from the first commit
$ hub pull-request --no-edit
copy

Create a new branch with the contents of a pull request and switch to it
$ hub pr checkout [pr_number]
copy

Upload the current (local-only) repository to your GitHub account
$ hub create
copy

Fetch Git objects from upstream and update local branches
$ hub sync
copy

SYNOPSIS

hub [args]

PARAMETERS

amend
    Amend the previous commit

browse
    Open a GitHub page in the browser.

checkout
    Checkout branches and pull requests.

ci-status
    Show the CI status of a commit.

clone
    Clone a repository.

compare
    Open a compare page on GitHub.

create
    Create a new GitHub repository.

delete
    Delete a remote repository on GitHub.

issue
    List and manage GitHub issues.

pr
    Create and manage GitHub pull requests.

release
    Manage GitHub releases.

fork
    Make a fork of the GitHub repository on GitHub and add as remote.

sync
    Update a local branch from remote.

DESCRIPTION

hub is a command-line tool that makes working with GitHub easier. It wraps the git command and provides additional features like creating repositories, creating pull requests, browsing issues, and more, directly from the terminal. It leverages the GitHub API to streamline common GitHub workflows. hub aims to improve the efficiency of developers working on GitHub projects by reducing the need to constantly switch between the terminal and the web browser. With hub you can do most of the important things without leaving the command line. hub is especially useful in scripts, where it will be more performant than multiple calls to GitHub's API.

CAVEATS

Requires a GitHub account and properly configured GitHub API token. The configuration is usually stored in ~/.config/hub.

CONFIGURATION

hub relies on a configuration file typically located in ~/.config/hub to store your GitHub credentials and other settings. This file needs to be properly configured for hub to interact with the GitHub API.

AUTHENTICATION

hub uses OAuth for authentication with GitHub. When you run hub for the first time, it will prompt you to authenticate and authorize the tool to access your GitHub account.

HISTORY

hub was created to address the limitations of the standard git command when interacting with GitHub. It provides a more streamlined and efficient workflow for GitHub-specific tasks. Development has been ongoing, with features added and improvements made based on community feedback. hub is now a popular tool among GitHub users for enhancing their command-line experience.

SEE ALSO

git(1)

Copied to clipboard