1. git-brws(1)
  2. git-brws(1)

NAME

git-brws - open a repository, file, commit, diff, pull request or issue in your web browser

SYNOPSIS

git brws
git brws file...
git brws file#lnum...
git brws branch
git brws commit
git brws tag
git brws commit..commit
git brws commit...commit
git brws --repo repo
git brws --pr
git brws --website

DESCRIPTION

git-brws is a command line tool to open a repository, file, commit, diff, tag, blame, pull request, issue or project's website in your web browser from command line. 'brws' is an abbreviation of 'browse'.

Example of pages which git-brws can open are:

git-brws prefers permlink to the latest page since the latest page will change when new commit is pushed to the branch.

SERVICES

git-brws supports GitHub, GitHub Enterprise, BitBucket, GitLab as Git repository hosting services.

OPTIONS

In addition to arguments described in SERVICES, following options are available as command line arguments. All are optional.

-r, --repo REPO

Specify which repository should be open. REPO is one of (1) shorthand format (repo, user/repo, host/user/repo) or (2) Git URL you want to see. When only repository name is specified, git-brws searches GitHub with query '{repo} in:name' and opens the best-matched repository page.

-b, --branch BRANCH

Branch name to browse. Default value is current branch.

-d, --dir PATH

Directory path to the repository. Default value is current working directory.

-R, --remote REMOTE

Remote name (e.g. origin). Default value is a remote the current branch is tracking. If current branch tracks no branch, it falls back to 'origin'.

-u, --url

Output URL to stdout instead of opening in browser.

-p, --pr

Open pull request page instead of repository page. If not existing, open 'Create Pull Request' page.

-w, --website

Open website page instead of repository page (homepage URL for GitHub, GitLab pages, Bitbucket Cloud)

-B, --blame

Open blame page instead of repository page. File path to blame must be passed also.

-h, --help

Print this help.

-v, --version

Show version.

EXAMPLES

Current repository page.

$ git brws

'develop' branch.

$ git brws -b develop

'origin' remote of 'develop' branch.

$ git brws -r origin -b develop

@rhysd's 'Shiba' repository on GitHub.

$ git brws -r rhysd/Shiba
$ git brws -r react

Repository specified by directory.

$ git brws -d ~/.go/src/github.com/rhysd/dot-github

File of current branch of current remote.

$ git brws ./some/file.txt

Line of the file.

$ git brws ./some/file.txt#L123

Note: The 'L' can be omit.

Range from line to line of the file.

$ git brws ./some/file.txt#L123-L126

Note: The 'L' can be omit.

'HEAD' page of current repository.

$ git brws HEAD

'0.10.0' tag page of current repository

$ git brws 0.10.0

Diff between 'HEAD' and 'HEAD~3'.

$ git brws HEAD~3..HEAD

Diff between '113079b' and '60024ab'.

$ git brws 60024ab..113079b

In addition to '..', diff with '...' is supported.

Diff between 'branchB' and the merge base commit from 'branchB' into 'branchA'

$ git brws branchA...branchB

Note: If you don't know the difference between '..' and '...', please read 'git diff --help'.

Note: Only GitHub and GitHub Enterprise support '...'. For GitLab, only '...' is available.

Pull request page of current branch of current repository.

$ git brws --pr

Note: When a pull request page for current branch is not existing yet, it opens 'Create Pull Request' page instead.

Pull request page of specific branch of specific repository.

# Specify my forked repository
$ git brws --pr --repo rhysd/rust.vim -b async-contextual-keyword

# Or specify original repository
$ git brws --pr --repo rust-lang/rust.vim -b async-contextual-keyword

Note: Currently only GitHub and GitHub Enterprise are supported.

Note: If you have created multiple pull requests at the same repository with the same branch name, the command may not open a pull request page you want.

Note: When a pull request page for current branch is not existing yet, it opens 'Create Pull Request' page instead.

Website for the repository

# Website for current repository
$ git brws --website
# Website of other repository
$ git brws --website --repo git-brws

Note: It opens a website for the repository.

An issue page.

$ git brws '#8'

Note: '#' is usually used for a line comment in major shells. Please quote the argument

Blame a file

$ git brws --blame some/file.txt

Blame specific line of a file

$ git brws --blame some/file.txt#L5

Blame specific range of a file

$ git brws --blame some/file.txt#L5-L9

ENVIRONMENT

$GIT_BRWS_GIT_COMMAND

Git command to use. If not specified, "git" will be used.

$GIT_BRWS_GHE_URL_HOST

When you use your own GitHub Enterprise repository, you can specify its host to this variable. By default, git-brws detects '^github.' as GHE host. If your GHE repository host does not match it, please specify this variable. If your repository is 'https://example-repo.org/user/repo', 'example-repo.org' should be set.

$GIT_BRWS_GHE_SSH_PORT

When you set a number to it, the number will be used for the ssh port for GitHub Enterprise URLs.

$GIT_BRWS_GITLAB_SSH_PORT

When you set a number to it, the number will be used for the ssh port for self-hosted GitLab URLs. This is useful when your environment hosts GitLab to non-trivial ssh port URL.

$GIT_BRWS_GITHUB_TOKEN

This variable is used for '--pr' (or '-p') only. API access token for github.com. They are optional, but useful for avoiding API rate limit and accessing to private repositories. Please generate a token from https://github.com/settings/tokens/new

$GITHUB_TOKEN

Ditto. When $GIT_BRWS_GITHUB_TOKEN is not set, $GITHUB_TOKEN is looked.

$GIT_BRWS_GHE_TOKEN

This variable is used for '--pr' (or '-p') only. API access token for GitHub Enterprise instance. It is sometimes mandatory (depending on your GHE instance configuration). Please generate a token from 'https://{YOUR GHE HOST}/settings/tokens/new'.

$GIT_BRWS_BROWSE_COMMAND

Command to open URL. If this value is specified, the command is executed with URL as first argument to browse the URL.

$https_proxy

This variable is used for '--pr' (or '-p') only. A HTTPS Proxy server URL if you use a web proxy.

REPOSITORY

git-brws is developed at repository hosted on GitHub.

https://github.com/rhysd/git-brws

BUGS

Please visit issues page to see known bugs. If you've found a new bug, please report it here.

https://github.com/rhysd/git-brws/issues

git-brws is licensed under the MIT License Copyright (c) 2016 rhysd

SEE ALSO

GIT(1)

  1. January 2020
  2. git-brws(1)