LinuxCommandLibrary

git-browse

Open Git repository in a web browser

TLDR

Open the first upstream in the default browser

$ git browse
copy

Open a specific upstream in the default browser
$ git browse [upstream]
copy

SYNOPSIS

git browse [remote] [branch]

PARAMETERS

remote
    Remote repository name (defaults to origin)

branch
    Branch or tag name to open (defaults to current HEAD branch)

DESCRIPTION

git-browse is a utility from the git-extras package that simplifies accessing your Git repository or specific branches on web-based hosting platforms like GitHub, GitLab, Bitbucket, or Gitea directly from the command line.

It intelligently parses the remote repository URL to detect the hosting service, constructs the correct web URL for the specified (or current) branch, and launches it in your default browser using tools like xdg-open.

This command is especially useful for developers who frequently switch between terminal workflows and web interfaces for code review, issue tracking, or pull requests without manually copying URLs.

For instance, with a GitHub remote named origin, git browse opens the current branch's tree view. It supports both branches and tags, falling back gracefully if the remote lacks detectable host patterns.

Installation is straightforward via package managers on most Linux distros, making it a lightweight addition to core Git.

CAVEATS

Requires git-extras package installed; only supports HTTPS remotes with detectable hosts (e.g., github.com); may fail on custom/private hosts without URL patterns.

INSTALLATION

Debian/Ubuntu: sudo apt install git-extras
Fedora: sudo dnf install git-extras
Or RubyGems: gem install git-extras

EXAMPLES

git browse — Opens current branch on origin
git browse upstream develop — Opens develop branch on upstream remote

HISTORY

Part of git-extras, created by Linus Olsson in 2011; git-browse added early in development (pre-2013) to enhance Git workflow integration with web forges.

SEE ALSO

Copied to clipboard