gh-browse
Open a GitHub repository in the 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 settings page of the current repository in the default web browser
Open the wiki of the current repository in the default web browser
Open a specific issue or pull request in the web browser
Open a specific branch in the web browser
Open a specific file or directory of the current repository in the web browser
Print the destination URL without open the web browser
SYNOPSIS
gh browse [path] [flags]
gh browse [repository] [--commit | --diff | --files | --find | --issue | --pull | --wiki] [flags]
gh browse url
PARAMETERS
--branch name
Selects a specific branch to open in the browser.
--commit hash
Opens the specified commit in the browser.
--diff
Opens the diff view for the current branch in the browser.
--files
Opens the 'Files changed' tab for the current pull request in the browser.
--find string
Navigates to a specific file or directory within the repository in the browser.
--issue [number]
Opens the issue list or a specific issue by number in the browser.
--no-browser
Prints the generated URL to standard output instead of opening it in the browser.
--pull [number]
Opens the pull request list or a specific pull request by number in the browser.
--repo [HOST/]OWNER/REPO
Specifies a repository other than the current one to browse.
--wiki
Opens the repository's wiki page in the browser.
DESCRIPTION
gh browse is a subcommand of the GitHub CLI (gh) that provides a convenient way to open various GitHub resources directly in your default web browser. It eliminates the need for manual navigation to GitHub URLs by allowing users to quickly access the current repository, a specific repository, an issue, a pull request, a commit, or a wiki page from the command line. This command significantly streamlines the developer workflow, offering immediate access to web-based views of project components like code, discussions, and project boards. It's an essential tool for developers who frequently interact with GitHub from their terminal.
CAVEATS
This command requires the GitHub CLI (gh) to be installed and properly authenticated with your GitHub account. It relies on your system's default web browser or the browser specified by the BROWSER environment variable. For implicit repository detection, the command must be executed within a Git repository that is linked to a GitHub remote, or the --repo flag must be explicitly used.
USAGE EXAMPLES
Open the current repository's main page:
gh browse
Open issue number 123 in the current repository:
gh browse --issue 123
Open pull request 456 in the 'cli/cli' repository:
gh browse cli/cli --pull 456
Print the URL of the current repository without opening it:
gh browse --no-browser
Open the 'main.go' file in the current repository on GitHub:
gh browse main.go
Open a specific GitHub URL:
gh browse github.com/cli/cli/issues/1
ENVIRONMENT VARIABLES
BROWSER: Specifies the browser command to use instead of the system's default browser for opening URLs.
HISTORY
gh-browse is a fundamental component of the GitHub CLI (gh) project, which was developed by GitHub to provide a robust and native command-line interface for interacting with its platform. The gh CLI, including the browse subcommand, gained significant adoption after its general availability release in 2020. The inclusion of gh browse from early development stages underscores the critical need for quick web access to GitHub resources, reflecting its utility in modern development workflows. Its ongoing development is part of the broader evolution of the gh CLI, continuously improving user experience and adding new functionalities.