LinuxCommandLibrary
GitHubF-DroidGoogle Play Store

git-browse

Open repository in web browser

TLDR

Open the current repository in the browser, using its current commit/branch
$ git browse
copy
Open a specific remote's repository
$ git browse [upstream]
copy
Open a specific file on a remote
$ git browse [upstream] [path/to/file]
copy
Jump to a specific line in a file
$ git browse [upstream] [path/to/file] [42]
copy
Jump to a range of lines in a file
$ git browse [upstream] [path/to/file] [1] [42]
copy

SYNOPSIS

git browse [remote-name] [filename] [line1] [line2]

DESCRIPTION

git browse is a git-extras command that detects the current repository's remote URL and opens it in the default web browser. It recognizes GitHub, GitLab, and Bitbucket remotes and builds the correct web URL format for each, including deep links to a specific file and line (or line range) at the current commit or branch.SSH remotes (git@host:user/repo.git) are converted to HTTPS automatically. Without a filename, it just opens the repository's landing page for the current commit/branch.

PARAMETERS

REMOTE-NAME

Remote to browse; defaults to the current branch's tracked remote, or origin.
FILENAME
Path (relative to repo root) of a file to open on the remote.
LINE1
Starting line number to highlight (requires filename).
LINE2
Ending line number, to highlight a range (requires line1).

INSTALL

sudo apt install git
copy
sudo dnf install git
copy
sudo pacman -S git
copy
sudo apk add git
copy
sudo zypper install git
copy
brew install git
copy
nix profile install nixpkgs#git
copy

CAVEATS

Only recognizes GitHub, GitLab, and Bitbucket remote URL formats. Requires a browser opener (open, xdg-open, or start) available on the system.

SEE ALSO

RESOURCES

Copied to clipboard
Kai