hub-branch
Create a GitHub repository branch
TLDR
Show the name of the currently active branch
Create a new branch
SYNOPSIS
hub branch [options...] [newbranch [start-point]]
PARAMETERS
-a, --all
list both remote-tracking and local branches
-r, --remotes
list remote-tracking branches only (fetches from GitHub)
-d, --delete <branch>…
delete branch(es), together with remote-tracking branch if it exists
-D
shortcut for -d --delete-force (-d -f)
-m, --move <branch> <newname>
rename <branch> to <newname>
-M
shortcut for -m --move-force (-m -f)
--no-color
do not colorize the output
--color[={always|never|auto}]
control colored output (default: auto)
DESCRIPTION
hub branch is a subcommand of the hub CLI tool, which extends git branch functionality with seamless GitHub awareness. It lists local and remote branches, creates new ones, deletes, renames, and more.
Running hub branch without arguments displays local branches, highlighting the current one with an asterisk. Use -r to list remote-tracking branches fetched directly from GitHub, or -a for both local and remote. Creating a branch is simple: hub branch new-feature creates and switches to the new branch based on current HEAD. Hub automatically configures tracking for GitHub remotes.
Deletion with -d removes local branches and their remote counterparts if they exist. Rename via -m. Colors are used by default for readability, configurable with --color or --no-color.
Ideal for GitHub workflows, it reduces manual git fetch calls by querying GitHub API for up-to-date branch lists, enhancing productivity in team environments.
CAVEATS
Requires hub installed and GitHub authentication (token or SSH). Not included in standard Linux distributions; install via package managers like brew or apt. Mirrors git branch but adds GitHub API calls which may fail without network/auth.
CREATING A BRANCH
hub branch new-feature
Creates local branch new-feature from current HEAD and checks it out.
hub branch new-feature origin/main
Creates from specific start-point.
DELETING REMOTE-SYNCED BRANCH
hub branch -d old-branch
Deletes local and pushes deletion to GitHub remote.
HISTORY
Introduced in early versions of hub (circa 2011) by Miroslav Bajtoš (mislav). Evolved with GitHub CLI features until 2021, when hub was archived in favor of gh (GitHub CLI), but remains widely used.
SEE ALSO
git-branch(1), hub(1)


