hub-browse
Open GitHub repository in a web browser
TLDR
Open the homepage of the current repository in the default web browser
Open the homepage of a specific repository in the default web browser
Open the subpage of a specific repository in the default web browser, subpage can be "wiki", "commits", "issues", or other (default: "tree")
SYNOPSIS
hub browse [OPTIONS] [ARGUMENTS]
hub browse [-u | --url]
hub browse [-p | --pull-request [PULL_REQUEST_NUMBER]]
hub browse [-b | --branch BRANCH]
hub browse [-f | --file PATH]
hub browse [-c | --commit COMMIT]
hub browse [URL]
PARAMETERS
-u, --url
Prints the full URL to standard output instead of opening it in a web browser.
-p, --pull-request
Opens the pull request page. If PULL_REQUEST_NUMBER is provided, opens that specific pull request. If omitted, opens the pull request for the current branch, or the list of all pull requests if no specific PR is associated.
-b, --branch BRANCH
Opens the GitHub page for the specified BRANCH. Defaults to the current branch if no branch is specified and contextual browsing is active.
-f, --file PATH
Opens the GitHub page for the specified file or directory PATH within the repository. If PATH is a directory, it opens the tree view.
-c, --commit COMMIT
Opens the GitHub page for the specified COMMIT hash or reference.
-s, --ssh
Generates the URL using the SSH-style Git remote (e.g., git@github.com:...). By default, it uses the HTTP/S URL.
URL
Directly opens the specified URL in the web browser, bypassing repository context inference.
-c N (with -p)
When used with -p, opens the specific comment number N on the pull request page.
DESCRIPTION
hub browse is a powerful command that seamlessly integrates your local Git repository with its corresponding GitHub web interface. Part of the hub toolkit, it extends standard git commands by adding GitHub-specific functionalities, making web browsing of repositories incredibly convenient. Instead of manually navigating to GitHub.com and searching for your project, hub browse intelligently infers the correct URL from your current Git repository's remote configuration. It can open the root of your repository, specific files or directories, branches, commits, or even pull requests directly in your default web browser. This command significantly enhances developer workflow by reducing context switching and manual URL typing, making it a staple for anyone frequently interacting with GitHub repositories. It's particularly useful for quickly sharing links to specific code sections or project pages.
CAVEATS
hub browse relies on the following:
* The hub command-line tool must be installed and accessible in your system's PATH.
* Your local Git repository must have a configured remote pointing to a GitHub repository. It primarily infers context from the origin remote, but can often work with others if they are GitHub-hosted.
* Your operating system must have a default web browser configured to handle HTTP/S URLs.
* It assumes a typical GitHub URL structure. While hub is robust, highly customized GitHub Enterprise instances might require additional configuration.
EXAMPLES
Here are some common usage examples for hub browse:
Open repository root:
hub browse
Open current branch's pull request:
hub browse -p
Open specific pull request (e.g., PR #123):
hub browse -p 123
Open a file in the current directory:
hub browse -f README.md
Open a file in a subdirectory:
hub browse -f src/main.go
Open a specific branch:
hub browse -b feature-branch
Open a specific commit:
hub browse -c a1b2c3d4
Print URL instead of opening browser:
hub browse -u -f README.md
Open an arbitrary URL:
hub browse https://github.com/github/hub/pulls
HISTORY
The hub project was initiated by Mislav Marohnić to extend the git command-line interface with functionalities specifically tailored for GitHub. Created to streamline common GitHub workflows that previously required visiting the website or using API calls, hub browse emerged as a core utility. Its development focused on leveraging existing Git repository information (remotes, branches, commits) to intelligently construct GitHub URLs, thereby bridging the gap between local development and the web platform. It has evolved alongside GitHub's features, adapting to new URL structures and providing quick access to features like pull requests and specific file views.
SEE ALSO
hub(1), git(1), git-remote(1), git-config(1)