hub(1)
π hub(1) β the hub manual, bestie π
okay so welcome to the hub manual, bestie β this is the page that makes git easier with GitHub, and weβre gonna get through it together β¨
π NAME π
hub β make git easier with GitHub π«Ά
β¨ SYNOPSIS β¨
hub [--noop] COMMAND [OPTIONS]
hub alias [-s] [SHELL]
hub help hub-COMMAND
π¦ DESCRIPTION π¦
So hub is a tool that wraps git and extends it with extra functionality, and the whole point is that working with GitHub is just better this way. Itβs giving βgit but make it GitHub-aware,β no cap π
π COMMANDS π
Available commands are split into two groups: the ones that are already present in git but get extended through hub, and the custom ones that hub provides.
πΈ Extended git commands πΈ
hub-am(1)β Replicate commits from a GitHub pull request locally. πhub-apply(1)β Download a patch from GitHub and apply it locally. β¨hub-checkout(1)β Check out the head of a pull request as a local branch. πhub-cherry-pick(1)β Cherry-pick a commit from a fork on GitHub. πhub-clone(1)β Clone a repository from GitHub. π¦hub-fetch(1)β Add missing remotes prior to performinggit fetch. πhub-init(1)β Initialize a git repository and add a remote pointing to GitHub. π±hub-merge(1)β Merge a pull request locally with a message like the GitHub Merge Button. πhub-push(1)β Push a git branch to each of the listed remotes. πhub-remote(1)β Add a git remote for a GitHub repository. πhub-submodule(1)β Add a git submodule for a GitHub repository. π§
π¦ New commands provided by hub π¦
hub-alias(1)β Show shell instructions for wrappinggit. π«hub-api(1)β Low-level GitHub API request interface. π₯hub-browse(1)β Open a GitHub repository in a web browser. πhub-ci-status(1)β Display status of GitHub checks for a commit. βhub-compare(1)β Open a GitHub compare page in a web browser. πͺhub-create(1)β Create a new repository on GitHub and add a git remote for it. πhub-delete(1)β Delete a repository on GitHub. πhub-fork(1)β Fork the current repository on GitHub and add a git remote for it. π΄hub-gist(1)β Create and print GitHub Gists. πhub-pull-request(1)β Create a GitHub Pull Request. π«Άhub-pr(1)β Manage GitHub Pull Requests for the current repository. πhub-issue(1)β Manage GitHub Issues for the current repository. πhub-release(1)β Manage GitHub Releases for the current repository. πhub-sync(1)β Fetch git objects from upstream and update local branches. π
π§ CONVENTIONS π§
Most hub commands are supposed to be run in the 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. Itβs doing the detective work so you donβt have to π
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. Thatβs the hierarchy, bestie π
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. Itβs giving βI know your fork is the main character hereβ π
π 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. Itβs a whole little handshake, and honestly? iconic π₯
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 β so that one stays out of the saved config, bestie π
π 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. So yeah, it changes the URL vibe across the board β¨
π’ 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β If this environment variable is set, verbose logging will be printed tostderr. So you can see all the little details πHUB_CONFIGβ The file path wherehubconfiguration is read from and stored. IfXDG_CONFIG_HOMEis present, the default is$XDG_CONFIG_HOME/hub; otherwise itβs$HOME/.config/hub. The configuration file is also searched for inXDG_CONFIG_DIRSper XDG Base Directory Specification. ποΈHUB_PROTOCOLβ One of"https","ssh", or"git"as preferred protocol for git clone/push. πGITHUB_HOSTβ The GitHub hostname to default to instead of"github.com". π’GITHUB_TOKENβ OAuth token to use for GitHub API requests. πGITHUB_USERβ The GitHub username of the actor of GitHub API operations. π€GITHUB_PASSWORDβ The GitHub password used to exchange user credentials for an OAuth token that gets stored inhubconfiguration. If not set, it may be interactively prompted for on first run. πGITHUB_REPOSITORYβ A value in"OWNER/REPO"format that specifies the repository that API operations should be performed against. Currently only used to infer the default value ofGITHUB_USERfor API requests. π―
π BUGS π
bugs? bestie, take it here: β¨https://github.com/github/hub/issuesβ© π
π AUTHORS π
the icons who made this happen: β¨https://github.com/github/hub/contributorsβ© π
π SEE ALSO π
git(1), git-clone(1), git-remote(1), git-init(1), β¨https://github.com/github/hubβ©
okay bye bestie π«Ά β this was hub(1), from hub version 2.14.2, dated 07 Jan 2024. periodt π
π
π¦ where this page comes from
- opensuse-leap 16.0: hub 2.14.2-bp160.1.13 Β· MIT
- opensuse-leap 16.0: hub 2.14.2-bp160.1.13 Β· MIT
- opensuse-leap 16.0: hub 2.14.2-bp160.1.13 Β· MIT
- opensuse-leap 16.0: hub 2.14.2-bp160.1.13 Β· MIT
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms