hub-fork
Fork a GitHub repository on the command line
TLDR
Fork a GitHub repository by its slug
Fork a GitHub repository by its URL
Fork current GitHub repository, set remote name to origin
SYNOPSIS
hub fork [-o ORGANIZATION] [-r REMOTE] [REPOSITORY]
PARAMETERS
-o, --org <ORGANIZATION>
Fork to specified GitHub organization instead of your account.
-r, --remote <NAME>
After forking, add git remote <NAME> (default: origin) pointing to your fork.
[REPOSITORY]
Repository to fork (defaults to current git repository).
DESCRIPTION
hub fork is a command from the hub tool, a wrapper around git that adds GitHub integration. It creates a fork of the specified repository (or current one) on GitHub under your user account or an organization.
The command checks if you already have a fork; if so, it updates it to match the upstream repository. Optionally, it clones your new fork and adds a git remote pointing to it, streamlining workflows for pull requests and contributions.
Common use: In a cloned repo, run hub fork to create your fork, then push branches to it. Requires hub configured with GitHub credentials (via GITHUB_TOKEN or SSH keys). Ideal for open-source collaboration where direct push access is unavailable.
Note: Forking respects GitHub permissions; you must have fork access.
CAVEATS
hub is deprecated; use gh repo fork instead. Requires GitHub authentication and fork permissions.
EXAMPLES
hub fork
Forks current repo to your account and adds remote.
hub fork -o myorg -r upstream
Forks to 'myorg', adds remote 'upstream'.
POST-FORK WORKFLOW
After hub fork, use hub pull-request to create PRs from your fork.
HISTORY
Developed by Miroslav Koškár (mislav) around 2010 as GitHub git wrapper. Gained popularity for CLI workflows; deprecated by GitHub in 2021 favoring official gh CLI.


