Skip to content

repo-open

Usage
repo-open [-p|--print] [-r|--root]
repo-open --help

Opens the web page for the current repository’s origin remote in a browser (via open-url). Deep-links to the current branch when it exists on the remote, falling back to the remote’s default branch (main/master) otherwise, and to the current sub-directory when invoked below the repo root.

The remote URL is normalized from both HTTPS and SSH/scp forms (git@host:owner/repo.git, ssh://…, https://…). The web path layout is provider-specific; the provider is resolved in this order:

  1. git config browse.provider (per-repo or --global override) 2. Hostname heuristic (github / gitlab / gitea / bitbucket; codeberg → gitea) 3. Default: github-style layout

For a self-hosted host the heuristic can’t classify (e.g. a Gitea or GitLab instance on a custom domain), set the provider once:

git config browse.provider gitea

-p, --print Print the resolved URL instead of opening it
-r, --root Ignore the current sub-directory; link to the repo root
-h, --help Print usage and exit
0 URL opened, or resolved with -p/--print
1 Not a git repo, no origin remote, or browser launch failed

With -p/--print, the resolved repository URL, printed to stdout

Typo abbreviation: open-repo (expands to repo-open on space/enter).

Terminal window
repo-open # open current branch (+ subdir) in browser
repo-open --print # just print the URL
repo-open --root # repo home page for the current branch

Dependencies: open-url