hub README

The project's README from github.com/mislav/hub. As one markdown file: README.md.

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 https://github.com/rtomayko/tilt.git

# or, if you prefer the SSH protocol:
$ git config --global hub.protocol ssh
$ hub clone rtomayko/tilt
#=> git clone [email protected]: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, Ubuntu 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

hub (mislav/hub)

Searching Database…

23K ·GitHub
这是什么?hub 是一个命令行工具,它对 git 进行封装,增加了一些额外的功能和命令,让在 GitHub 上的操作更方便,比如在终端里创建 pull request 或 fork 仓库。
这是一个独立的工具,还是会替代 git?它是一个独立的可执行文件,在你现有的 git 外面做了一层封装,在普通 git 用法之上增加了 GitHub 专用的命令和参数。你也可以把它设置为 git 的别名,这样在命令行里输入 git 时实际运行的就是 hub。
我需要先安装 git 吗?hub 可执行文件本身没有依赖,但由于它封装了 git,你需要先安装 git 1.7.3 或更新的版本。
非 Homebrew 渠道的安装包是否总是最新的?不是。除 Homebrew 之外的安装包由社区维护,不保证与 hub 的最新版本一致,所以安装后请检查一下版本号。
在 Windows 上有没有用 PowerShell 设置的方法?有。你可以在 PowerShell 的配置文件中为 hub 设置别名,README 中提供了一行命令,可以添加别名,如果配置文件还不存在还会自动创建。
hub 和 GitHub 官方的 CLI 是一样的吗?不是。hub 是一个独立的、较早的社区项目;GitHub 官方的 CLI 位于 cli.github.com,README 中提供了两者的对比说明。
hub 支持 shell 的 Tab 自动补全吗?支持。代码仓库中提供了 bash、zsh 和 fish 的 Tab 自动补全脚本,可以与 git 已经提供的补全脚本配合使用。
可以用 hub 编写针对 GitHub API 的脚本吗?可以。你可以用 hub 编写 shell 脚本,直接与 GitHub API 交互,而不仅限于在终端里交互式使用。
可以在 GitHub Actions 工作流中使用 hub 吗?可以,hub 可以直接在 GitHub Actions 中使用。不过如果要调用跨仓库的 API,你需要一个具有 repo 权限范围的个人访问令牌,因为默认的 secrets.GITHUB_TOKEN 只限于当前运行的仓库。
Creator
mislav
Size
7.2 MB
Stars
23K
Age
16y
Commits · 90 Days