git-browse
Open Git repository in a web browser
TLDR
Open the first upstream in the default browser
Open a specific upstream in the default browser
SYNOPSIS
git browse [options] [ref] [file]
PARAMETERS
[ref]
Specify a Git reference (e.g., a branch name like main, a tag, or a commit hash like HEAD~1). If omitted, the command typically opens the current branch's page or the repository's root page on the remote host.
[file]
Specify a file path relative to the repository root. If provided, the command attempts to open that specific file's view on the remote host. This can be combined with a ref to browse a file at a particular commit or branch (e.g., git browse main README.md).
-r, --remote name
Specify a different remote name (e.g., upstream) to use instead of the default origin when inferring the base URL for the repository.
-u, --url
Instead of launching a web browser, print the constructed URL to standard output. This is useful for scripting or for users who prefer to open the URL manually.
-i, --issues
Open the issues page of the repository on the remote hosting service.
-p, --pulls
Open the pull requests (or merge requests) page of the repository on the remote hosting service.
-c, --commit hash
Open the specific page for a given commit hash. This option is often provided for clarity, even if similar functionality can be achieved by passing a commit hash as a ref argument.
-b, --blame
When browsing a specific file, open its 'blame' view on the remote host, which shows the last commit that modified each line (if supported by the hosting service).
DESCRIPTION
The command git-browse is not a standard Git command bundled with the official Git distribution. Instead, it is a widely adopted convenience alias or external script used to quickly open the current Git repository, a specific file, or a commit in the default web browser on its remote hosting service (e.g., GitHub, GitLab, Bitbucket). It typically infers the remote URL from the configured Git remotes (most commonly origin) and constructs the appropriate web URL based on the current branch, commit, or file path within the repository. This functionality saves users from manually copying remote URLs and navigating to them, making it particularly useful for quickly accessing project dashboards, browsing source code online, reviewing pull requests, or checking issue trackers directly from the command line interface.
CAVEATS
This command is not part of the official Git distribution and is not universally available by default. Its presence and exact behavior depend on whether it's provided by a third-party tool (such as hub or the gh CLI for GitHub), a custom shell alias, or a user-defined script. Therefore, its functionality, supported options, and how it handles different remote hosting services (GitHub, GitLab, Bitbucket, etc.) can vary significantly between different implementations. Users should consult the documentation for their specific git-browse installation.
CONFIGURATION AND HOSTING SERVICES
A robust git-browse implementation typically relies on Git's remote configuration to determine the type of hosting service (e.g., GitHub, GitLab) and then constructs the URL accordingly. Some versions may require additional configuration within the .git/config file or global Git configuration to correctly resolve URLs for less common hosting providers or private Git instances.
EXTERNAL DEPENDENCIES
The command usually depends on external tools for launching the web browser. Common dependencies include xdg-open on Linux, open on macOS, and start on Windows. Without these operating system-specific utilities, the command might fail to open the browser, although it could still print the URL if the --url option is used.
HISTORY
The concept behind git-browse arose from developers' frequent need to transition from the command line to a repository's web interface. Before its widespread adoption as a convenience alias or script, users would manually copy remote URLs and paste them into their browsers. This repetitive task spurred the creation of various user-contributed scripts and aliases to automate the process. Its utility was eventually recognized by command-line tools designed to extend Git's functionality, such as hub (GitHub's official command-line extension for Git) and gh (the GitHub CLI), which integrated similar browser-opening capabilities, often aliased or named git browse. This effectively 'standardized' the utility in developer workflows, even though it remains an external, rather than built-in, Git subcommand.
SEE ALSO
git(1), git-config(1), git-remote(1), hub(1)