A command-line tool that makes git easier to use with GitHub.

hub is a command line tool that wraps git in order to extend it with extra features and commands that make working with GitHub easier.

For an official, potentially more user-friendly command-line interface to GitHub, see cli.github.com and this comparison.

This repository and its issue tracker is not for reporting problems with GitHub.com web interface. If you have a problem with GitHub itself, please contact Support.

Usage

$ hub clone rtomayko/tilt
#=> git clone git://github.com/rtomayko/tilt.git

# if you prefer HTTPS to git/SSH protocols:
$ git config --global hub.protocol https
$ hub clone rtomayko/tilt
#=> git clone https://github.com/rtomayko/tilt.git

See usage examples or the full reference documentation to see all available commands and flags.

hub can also be used to make shell scripts that directly interact with the GitHub API.

hub can be safely aliased as git, so you can type $ git <command> in the shell and have it expanded with hub features.

Installation

The hub executable has no dependencies, but since it was designed to wrap git, it's recommended to have at least git 1.7.3 or newer.

platform manager command to run
macOS, Linux Homebrew brew install hub
macOS, Linux Nix nix-env -i hub
Windows Scoop scoop install hub
Windows Chocolatey choco install hub
Fedora Linux DNF sudo dnf install hub
Arch Linux pacman sudo pacman -S hub
FreeBSD pkg(8) pkg install hub
Debian apt(8) sudo apt install hub
Ubuntu Snap We do not recommend installing the snap anymore.
openSUSE Zypper sudo zypper install hub
Void Linux xbps sudo xbps-install -S hub
Gentoo Portage sudo emerge dev-vcs/hub
any conda conda install -c conda-forge hub

Packages other than Homebrew are community-maintained (thank you!) and they are not guaranteed to match the latest hub release. Check hub version after installing a community package.

Standalone

hub can be easily installed as an executable. Download the latest binary for your system and put it anywhere in your executable path.

GitHub Actions

hub is ready to be used in your GitHub Actions workflows:

steps:
- uses: actions/checkout@v2

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

Note that the default secrets.GITHUB_TOKEN will only work for API operations scoped to the repository that runs this workflow. If you need to interact with other repositories, generate a Personal Access Token with at least the repo scope and add it to your repository secrets.

Source

Prerequisites for building from source are:

Clone this repository and run make install:

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

Aliasing

Some hub features feel best when it's aliased as git. This is not dangerous; your normal git commands will all work. hub merely adds some sugar.

hub alias displays instructions for the current shell. With the -s flag, it outputs a script suitable for eval.

You should place this command in your .bash_profile or other startup script:

eval "$(hub alias -s)"

PowerShell

If you're using PowerShell, you can set an alias for hub by placing the following in your PowerShell profile (usually ~/Documents/WindowsPowerShell/Microsoft.PowerShell_profile.ps1):

Set-Alias git hub

A simple way to do this is to run the following from the PowerShell prompt:

Add-Content $PROFILE "`nSet-Alias git hub"

Note: You'll need to restart your PowerShell console in order for the changes to be picked up.

If your PowerShell profile doesn't exist, you can create it by running the following:

New-Item -Type file -Force $PROFILE

Shell tab-completion

hub repository contains tab-completion scripts for bash, zsh and fish. These scripts complement existing completion scripts that ship with git.

Meta

Owner
GitHub
How people build software.
GitHub
Comments
  • zsh completion is semi-broken

    zsh completion is semi-broken

    I have this in my .zshrc

    eval "$(hub alias -s)"
    
    • hub is installed via homebrew
    • zsh completion is installed to /usr/local/share/zsh/site-functions

    the hub commands like pull-request, browse etc doesn't get completed

    Ideas @mislav ?

  • Error creating pull request: Unprocessable Entity (HTTP 422)

    Error creating pull request: Unprocessable Entity (HTTP 422)

    I can't open a pull request with hub. This is what I do:

    $ git checkout -b new_branch
    ( some changes here)
    $ git commit -m "Test commit"
    $ git push origin new_branch
    $ hub pull-request
    

    And this is what I get from the last command:

    (username and password lines)
    Error creating pull request: Unprocessable Entity (HTTP 422)
    field 'head_sha' is missing
    field 'base_sha' is missing
    base No commits between user:master and user:new_branch
    
  • Upload File Type Bug on Attach files

    Upload File Type Bug on Attach files

    It says "We don't support that file type. Try again with a PNG, GIF, JPG, DOCX, PPTX, XLSX, TXT, PDF, or ZIP." when i'm trying to upload a .ZIP file. I even tried changing the .zip to .ZIP in my file.

  • Error creating pull request: Not Found (HTTP 404)

    Error creating pull request: Not Found (HTTP 404)

    $ hub pull_request -i 836 github.com username: myusername github.com password for myusername (never stored): Error creating pull request: Not Found (HTTP 404) Are you sure that github.com/myorg/myrepo exists?

    This repo exists and all other commands work except pull-request. Only for this command hub asks me for username/password

  • HTTP 401 while using 'create' action

    HTTP 401 while using 'create' action

    I am constantly hitting a HTTP 401 when trying to use

    hub create

    on my newly created project. Isn't the create action meant to auto create the project on github?

    Steps: ~: mkdir -p helloworld
    ~: cd helloworld helloworld: echo 'trying out hub gem' > README helloworld: hub init -g Initialized empty Git repository in /Users/berinle/helloworld/.git/ helloworld(master) ✗: hub add . helloworld(master) ✗: hub commit -m "first commit" [master (root-commit) b770670] first commit 1 files changed, 1 insertions(+), 0 deletions(-) create mode 100644 README helloworld(master): hub create error creating repository: Unauthorized (HTTP 401) helloworld(master):

    Please advice

  • [Feature] Create a

    [Feature] Create a "Draft" pull request

    What better time to request a feature in hub than moments after a feature is released in the GitHub UI! 😁 I love not having to go to the UI for common tasks, and I can see this new feature being included in my workflow for discussing a PR prior to wanting to merge it.

    Reference: https://github.blog/2019-02-14-introducing-draft-pull-requests/

    A cursory look at the API docs doesn't seem to have this available yet (I do see a "locked" flag), so this issue may hang out for a while.

  • Obtaining authentication from environment

    Obtaining authentication from environment

    I don't want to have a .config/hub file lying around on remote systems where I use hub. I'd prefer to communicate my password through the environment (since I can use ssh SendEnv, etc).

    I've tried using GITHUB_USER and GITHUB_PASSWORD with a token generated from https://github.com/settings/applications, but when I try to send a pull request I get "404 not found". It works if I send a pull request by entering my credentials and using .config/hub. Any ideas?

  • Make

    Make "git push" work with 2FA

    I have hub installed, but when I run git push from a repository, I get this (and I'm pretty sure it's 2FA):

    jkeiser@Ettores-MBP ~/s/chef-provisioning-aws> set -x GIT_TRACE 1
    jkeiser@Ettores-MBP ~/s/chef-provisioning-aws> git push
    Username for 'https://github.com': jkeiser
    Password for 'https://[email protected]':
    remote: Invalid username or password.
    fatal: Authentication failed for 'https://github.com/chef/chef-provisioning-aws.git/'
    

    I am entering the correct password (I know this because if I curl --user jkeiser https://api.github.com/orgs and enter the same password, I get back this:

    {
      "message": "Must specify two-factor authentication OTP code.",
      "documentation_url": "https://developer.github.com/v3/auth#working-with-two-factor-authentication"
    }
    

    I'd like for it to work. I'd LOVE for it to work by fixing git credential, because I'm using that from a Ruby library, but that's not this bug :)

  • Implement PR merge command

    Implement PR merge command

    Background

    Initially this was just a small hack in my local hub repo. After having used it without any issues almost every day for the past two years, I thought I would open this PR for discussion to see if others are also interested.

    Personally, I find it super convenient not having to open a browser/website to merge a PR (which I usually create from command line as well using hub pull-request).

    Details

    The GitHub API has offered a "merge" functionality for a long time:

    PUT /repos/:owner/:repo/pulls/:pull_number/merge
    

    See https://developer.github.com/v3/pulls/#merge-a-pull-request-merge-button

    So far, this was not supported by hub.

    I added a new hub pr merge <PR-NUMBER> command that takes the PR number and merges the PR (if the user has write access to the repo).

    Note: This is the first PUT route - I had to add a PutJSON function to github/http.go.

    Examples

    $ hub pr list
          #1  Create README.md
    
    # (Success case - PR 1 is merged, no output, exit code `0`)
    $ hub pr merge 1
    
    # (Error case, for example user has no write access)
    $ hub pr merge 1
    Error merging pull request: Not Found (HTTP 404)
    Not Found
    

    I also slightly updated the hub pr documentation to better reflect what it can do now.

    $ hub
    ...
    These GitHub commands are provided by hub:
    
    ...
       pr             Manage GitHub Pull Requests
    ...
    
    $ hub merge
    Usage: hub pr list [-s <STATE>] [-h <HEAD>] [-b <BASE>] [-o <SORT_KEY> [-^]] [-f <FORMAT>] [-L <LIMIT>]
           hub pr checkout <PR-NUMBER> [<BRANCH>]
           hub pr show [-uc] [-h <HEAD>]
           hub pr show [-uc] <PR-NUMBER>
           hub pr merge <PR-NUMBER>
    

    Future ideas

    Some ideas for the future (either as part of this PR or a follow up PR):

    • Improve error messages
    • Support different merge methods
    • Before the merge, see if all checks are configured and have passed - if not, abort merge
    • Allow "force" merging (if checks have not passed, see previous point)
    • Allow customizing the merge commit message
    • Add an option to automatically delete the PR head branch after successful merge
  • Persist GPG Verified Signed Commit On

    Persist GPG Verified Signed Commit On "Squash and Merge" and / or "Rebase and merge" In PRs

    On GitHub Enterprise (GHE) v2.7.x, when I make a Pull Request (PR) with a single commit on a feature branch that is signed with a verified GPG signature, and eventually merge this in via the click action on the button labelled Confirm squash and merge, the commit is no longer signed with a verified GPG signature. So my question is, could GPG signed verified commit(s) status(es) from feature branches please be persisted into the branch it is merging into in the PR squash and merge process? Or even when using the Rebase and merge option? At least especially if there is only one new commit, which is GPG signed from a feature branch.

  • New command: delete

    New command: delete

    @mlang raised a good point at the end of his blog post about not being able to delete a fork.

    What are your thoughts about this command delete? I see it useful in cases where I make a quick pull-request and then don't want to clutter my repos so I want to delete it right away. We could replicate the web interface by asking the user to type the name of the repo to confirm deletion. (We can also go a step further and only delete the repository if it's a fork?)

  • Msfs_mouse_yoke-0.3c

    Msfs_mouse_yoke-0.3c

    Hi! @matiaspedelhez

    Microsoft Flight Simulator (XboxGames) Msfs_mouse_yoke-0.3c Wow! PERFECT. Microsoft Flight Simulator (Steam) Msfs_mouse_yoke-0.3c FAIL.

    1. I uninstalled Microsoft Flight Simulator on XboxGames.
    2. I installed Microsoft Flight Simulator on Steam.
    3. Cmd opens msfs_mouse_yoke-0.3c and closes after 1

    20221224T0415114592.log

  • hub release create frequently fails with

    hub release create frequently fails with "The release was created, but attaching 15 assets failed", "write: connection reset by peer"

    I'm running hub release create inside GitHub Actions + Ubuntu 20.04 + Alpine 3.17. This error constantly breaks my Actions, this happens almost every time (but not always). The error is very cryptic. Is file size of the assets a problem? The largest of my assets is ~50Mb.

        runs-on: ubuntu-20.04
        container: alpine:3.17
        steps:
          - name: Install Prerequisites
            run:  apk add --update --no-cache libnsl libnsl-dev build-base coreutils cmake git xz wget perl gperf p7zip python3 strace && ln -sf python3 /usr/bin/python
    
          - name: Install Hub
            run:  apk add --no-cache -X http://dl-cdn.alpinelinux.org/alpine/edge/testing hub
    
    Attaching 17 assets...
    The release was created, but attaching 15 assets failed. You can retry with:
    hub release edit build_757f82[13](https://github.com/busytex/busytex/actions/runs/3740840368/jobs/6349685778#step:10:14)e3624672ff516e9b3d8d5a6ae16400b3 -m '' -a build/native/busytex -a build/native/busytex.tar -a build/native/texlive/libs/freetype2/ft-build/apinames -a build/native/texlive/libs/icu/icu-build/bin/icupkg -a build/native/texlive/libs/icu/icu-build/bin/pkgdata -a build/native/texlive/texk/web2c/ctangle -a build/native/texlive/texk/web2c/otangle -a build/native/texlive/texk/web2c/tangle -a build/native/texlive/texk/web2c/tangleboot -a build/native/texlive/texk/web2c/ctangleboot -a build/native/texlive/texk/web2c/tie -a build/native/texlive/texk/web2c/web2c/fixwrites -a build/native/texlive/texk/web2c/web2c/makecpool -a build/native/texlive/texk/web2c/web2c/splitup -a build/native/texlive/texk/web2c/web2c/web2c
    
    Error uploading release asset: Post https://uploads.github.com/repos/busytex/busytex/releases/86651807/assets?name=busytex: write tcp 172.18.0.2:47490->[14](https://github.com/busytex/busytex/actions/runs/3740840368/jobs/6349685778#step:10:15)0.82.114.14:443: write: connection reset by peer
    Error: Process completed with exit code 1.
    
  • Check for github action updates monthly

    Check for github action updates monthly

    This will use dependabot to check any github action which this project uses for updates on a monthly basis in order to keep it up-to-date.

    https://docs.github.com/en/code-security/dependabot/working-with-dependabot/keeping-your-actions-up-to-date-with-dependabot

  • `hub ci-status` does not handle API pagination

    `hub ci-status` does not handle API pagination

    Command attempted: hub ci-status and hub ci-status --verbose

    What happened: I have a repo with ~50 checks for CI. When a few of those checks fails, hub ci-status can incorrectly report success, and hub ci-status --verbose does not list all checks.

    The number of results indicate that only the first page in GitHub's API pagination is handled.

    More info: hub version 2.14.2

  • Can't get the output from

    Can't get the output from "hub sync" when piping

    Command attempted:

    I tried these commands to get the output of "hub sync": tmp="$(hub sync)" hub sync | read tmp read tmp < <(hub sync)

    What happened:

    echo "$tmp" always returns nothing

    More info:

    Did I miss anything?

A tasty, self-hosted Git server for the command line🍦
A tasty, self-hosted Git server for the command line🍦

Soft Serve A tasty, self-hosted Git server for the command line. ?? Configure with git Create repos on demand with git push Browse repos with an SSH-a

Jan 9, 2023
Git with a cup of tea, painless self-hosted git service
Git with a cup of tea, painless self-hosted git service

Gitea - Git with a cup of tea View the chinese version of this document Purpose The goal of this project is to make the easiest, fastest, and most pai

Jan 2, 2023
ReGit: A Tiny Git-Compatible Git Implementation written in Golang

ReGit is a tiny Git implementation written in Golang. It uses the same underlying file formats as Git. Therefore, all the changes made by ReGit can be checked by Git.

Oct 31, 2022
A Git RPC service for handling all the git calls made by GitLab
A Git RPC service for handling all the git calls made by GitLab

Quick Links: Roadmap | Want to Contribute? | GitLab Gitaly Issues | GitLab Gitaly Merge Requests | Gitaly is a Git RPC service for handling all the gi

Nov 13, 2021
Removes unnecessarily saved git objects to optimize the size of the .git directory.

Git Repo Cleaner Optimizes the size of the .git directory by removing all of the files that are unnecessarily-still-saved as part of the git history.

Mar 24, 2022
Gum - Git User Manager (GUM) - Switch between git user profiles
Gum - Git User Manager (GUM) - Switch between git user profiles

Git User Manager (GUM) Add your profile info to config.yaml Build project: go bu

Feb 14, 2022
Git-now-playing - Git commits are the new AIM status messages

git-now-playing git-now-playing is an attempt to bring some of the panache of th

Apr 4, 2022
A tool to monitor git repositories and automatically pull & push changes

git-o-matic A tool to monitor git repositories and automatically pull & push changes Installation Packages & Binaries Arch Linux: gitomatic Binaries f

Dec 20, 2022
A simple tool to help apply changes across many GitHub repositories simultaneously
A simple tool to help apply changes across many GitHub repositories simultaneously

A simple tool to help apply changes across many GitHub repositories simultaneously

Dec 22, 2022
Gogs is a painless self-hosted Git service
Gogs is a painless self-hosted Git service

Gogs - A painless self-hosted Git service 简体中文 ?? Vision The Gogs (/gɑgz/) project aims to build a simple, stable and extensible self-hosted Git servi

Jan 9, 2023
A highly extensible Git implementation in pure Go.
A highly extensible Git implementation in pure Go.

go-git is a highly extensible git implementation library written in pure Go. It can be used to manipulate git repositories at low level (plumbing) or

Jan 8, 2023
commit/branch/workdir explorer for git

gitin gitin is a commit/branch/status explorer for git gitin is a minimalist tool that lets you explore a git repository from the command line. You ca

Dec 31, 2022
SQL interface to git repositories, written in Go. https://docs.sourced.tech/gitbase

gitbase gitbase, is a SQL database interface to Git repositories. This project is now part of source{d} Community Edition, which provides the simplest

Dec 25, 2022
Fast and powerful Git hooks manager for any type of projects.
Fast and powerful Git hooks manager for any type of projects.

Lefthook The fastest polyglot Git hooks manager out there Fast and powerful Git hooks manager for Node.js, Ruby or any other type of projects. Fast. I

Jan 4, 2023
Implementation of git internals from scratch in Go language
Implementation of git internals from scratch in Go language

This project is part of a learning exercise to implement a subset of "git" commands. It can be used to create and maintain git objects, such as blobs, trees, commits, references and tags.

Nov 27, 2022
A Simple and Comprehensive Vulnerability Scanner for Container Images, Git Repositories and Filesystems. Suitable for CI
A Simple and Comprehensive Vulnerability Scanner for Container Images, Git Repositories and Filesystems. Suitable for CI

A Simple and Comprehensive Vulnerability Scanner for Containers and other Artifacts, Suitable for CI. Abstract Trivy (tri pronounced like trigger, vy

Jan 9, 2023
go mod vendor lets you check in your dependencies to git, but that's both bloaty (for developers) and tedious (remembering to update it).

go-mod-archiver Afraid of being unable to build historical versions of your Go program? go mod vendor lets you check in your dependencies to git, but

Dec 1, 2022
Quickly clone git repositories into a nested folders like GOPATH.

cl cl clones git repositories into nested folders like GOPATH and outputs the path of the cloned directory. Example: cl https://github.com/foo/bar Is

Nov 30, 2022
Switch between your git profiles easily
Switch between your git profiles easily

Git Profile Switcher Switch between your git profiles easily Install With Brew brew install theykk/tap/git-switcher With golang go get github.com/the

Dec 11, 2022