table of contents
hub(1) | hub manual | hub(1) |
NAME¶
hub - make git easier with GitHub
SYNOPSIS¶
hub [--noop] COMMAND [OPTIONS]
hub alias [-s] [SHELL]
hub help hub-COMMAND
DESCRIPTION¶
Hub is a tool that wraps git in order to extend it with extra functionality that makes it better when working with GitHub.
COMMANDS¶
Available commands are split into two groups: those that are already present in git but that are extended through hub, and custom ones that hub provides.
Extended git commands¶
New commands provided by hub¶
CONVENTIONS¶
Most hub commands are supposed to be run in a context of an existing local git repository. Hub will automatically detect the GitHub repository that the current working directory belongs to by scanning its git remotes.
In case there are multiple git remotes that are all pointing to GitHub, hub assumes that the main one is named "upstream", "github", or "origin", in that order of preference.
When working with forks, it´s recommended that the git remote for your own fork is named "origin" and that the git remote for the upstream repository is named "upstream". See ⟨https://help.github.com/articles/configuring-a-remote-for-a-fork/⟩
The default branch (usually "master") for the current repository is detected like so:
git symbolic-ref refs/remotes/origin/HEAD
where origin is the name of the git remote for the upstream repository.
The destination where the currently checked out branch is considered to be pushed to depends on the git config push.default setting. If the value is "upstream" or "tracking", the tracking information for a branch is read like so:
git rev-parse --symbolic-full-name BRANCH@{upstream}
Otherwise, hub scans git remotes to find the first one for which refs/remotes/REMOTE/BRANCH exists. The "origin", "github", and "upstream" remotes are searched last because hub assumes that it´s more likely that the current branch is pushed to your fork rather than to the canonical repo.
CONFIGURATION¶
GitHub OAuth authentication¶
Hub will prompt for GitHub username password the first time it needs to access the API and exchange it for an OAuth token, which it saves in ~/.config/hub.
To avoid being prompted, use GITHUB_USER and GITHUB_PASSWORD environment variables.
Alternatively, you may provide GITHUB_TOKEN, an access token with repo permissions. This will not be written to ~/.config/hub.
HTTPS instead of git protocol¶
If you prefer the HTTPS protocol for git operations, you can configure hub to generate all URLs with https: instead of git: or ssh::
$ git config --global hub.protocol https
This will affect clone, fork, remote add and other hub commands that expand shorthand references to GitHub repo URLs.
GitHub Enterprise¶
By default, hub will only work with repositories that have remotes which point to github.com. GitHub Enterprise hosts need to be whitelisted to configure hub to treat such remotes same as github.com:
$ git config --global --add hub.host MY.GIT.ORG
The default host for commands like init and clone is still github.com, but this can be affected with the GITHUB_HOST environment variable:
$ GITHUB_HOST=my.git.org git clone myproject
Environment variables¶
HUB_VERBOSE
HUB_CONFIG
HUB_PROTOCOL
GITHUB_HOST
GITHUB_TOKEN
GITHUB_USER
GITHUB_PASSWORD
GITHUB_REPOSITORY
BUGS¶
⟨https://github.com/github/hub/issues⟩
AUTHORS¶
⟨https://github.com/github/hub/contributors⟩
SEE ALSO¶
git(1), git-clone(1), git-remote(1), git-init(1), ⟨https://github.com/github/hub⟩
07 Jan 2024 | hub version 2.14.2 |