macOS · Linux · Windows · WSL — a single static binary that opens the current Git repository in your browser, with no runtime dependencies and no configuration.
Important
After installation, just run git open:
git openRun it inside any Git repository and that repository opens in your browser —
on your current branch. That's the whole workflow; git-open works too, since
git treats it as the open subcommand. The supported hosts are listed under
Hosts and branch URLs; hosts without a known branch
URL still open the repository root, and any host can be mapped to a style in
the config file.
The fastest way is a package manager:
mise (macOS · Linux · WSL):
mise use -g github:zhaochunqi/git-openNix:
nix profile install github:zhaochunqi/git-openHomebrew (macOS):
brew install --cask zhaochunqi/tap/git-openPrebuilt binaries are published for every supported platform as well. Pick the asset that matches your machine and follow Installation Options:
| Platform | Release asset |
|---|---|
| macOS (Intel / Apple Silicon) | git-open_Darwin_x86_64.tar.gz / git-open_Darwin_arm64.tar.gz |
| Linux (x86_64 / arm64) | git-open_Linux_x86_64.tar.gz / git-open_Linux_arm64.tar.gz |
| Windows (x86_64 / arm64) | git-open_Windows_x86_64.zip / git-open_Windows_arm64.zip |
| WSL (WSL1 / WSL2) | install the Linux binary inside your distro — see WSL |
- Cross-platform by design — macOS (Intel / Apple Silicon), Linux (x86_64 / arm64) and Windows (x86_64 / arm64), plus WSL.
- WSL aware — inside WSL the URL is handed to your Windows default browser, so no
WSLg, X server or
xdg-openis required. - Branch aware — opens the current branch, while
main/masterfall back to the repository root. - Host aware, vendor neutral — GitHub, GitLab, Bitbucket, Gitea/Forgejo/Codeberg,
SourceHut and Azure DevOps are recognised by hostname. Any other host can be mapped to a
named style (
github,gitlab,gitea, ...) or a raw path template in the config file, and unknown hosts open the repository root instead of a guessed URL. - Configurable browser —
~/.config/git-open/config.yaml(browser: ...), following the XDG Base Directory spec, or theBROWSERenvironment variable. git -Cstyle-Cflag — run as if started in another directory.- Lightweight — one static binary per platform and no runtime dependencies.
git-open picks the branch URL from the remote's hostname, so the same command works on
every supported service. These hosts are recognised out of the box — the style column
is the name you use in the config file:
| Host pattern | Style | Branch URL |
|---|---|---|
github.com |
github |
/tree/<branch> |
gitlab.com |
gitlab |
/-/tree/<branch> |
bitbucket.org |
bitbucket |
/src/<branch> |
codeberg.org, gitea.com |
gitea |
/src/branch/<branch> |
git.sr.ht |
sourcehut |
/tree/<branch> |
dev.azure.com, *.visualstudio.com |
azure-devops |
?version=GB<branch> |
any hostname with a gitlab label, e.g. gitlab.example.com |
gitlab |
/-/tree/<branch> |
any hostname with a gitea or forgejo label |
gitea |
/src/branch/<branch> |
On main / master, and on any host that is not in the table, git-open opens the
repository root instead. A host is never guessed: GitHub Enterprise, Azure DevOps Server
and self-hosted instances on a neutral domain such as git.example.com stay at the root
until you map them to a style (or to none to keep them there) under
Repository hosts.
| Platform | Status | How the URL is opened |
|---|---|---|
| macOS | supported | open |
| Linux | supported | xdg-open |
| Windows | supported | cmd /c start |
| WSL (WSL1 / WSL2) | supported | xdg-open → wslview → explorer.exe → powershell.exe → cmd.exe |
| Others (FreeBSD, Plan 9, ...) | not supported | exits with unsupported platform: <goos> |
WSL is detected from WSL_DISTRO_NAME / WSL_INTEROP, with the /proc/version
kernel string (microsoft) as a fallback. Any platform can be overridden with the
browser option — see Configuration and
WSL.
Package managers are the easiest route; use the prebuilt binaries if you would rather install manually.
For users who prefer mise for version management (works on macOS, Linux and WSL):
Install the latest release globally:
mise use -g github:zhaochunqi/git-openOr pin a specific release:
mise use -g github:zhaochunqi/git-open@2.9.0This uses mise's github backend, which
installs pre-built binaries straight from GitHub Releases. The older
ubi:zhaochunqi/git-open syntax still works but is
deprecated — migrate by replacing ubi: with
github: in your existing config. The equivalent mise.toml entry is:
[tools]
"github:zhaochunqi/git-open" = "latest"Using flakes (recommended):
One-shot run without installing:
nix run github:zhaochunqi/git-openInstall into your profile:
nix profile install github:zhaochunqi/git-openOr pin a release tag:
nix profile install github:zhaochunqi/git-open/v2.9.0From a local checkout:
nix build
./result/bin/git-open versionDevelopment shell with Go toolchain:
nix developThis tap ships a cask, and Homebrew casks only work on macOS. (Homebrew itself also runs on Linux, but without cask support.) On Linux, use mise, Nix or the prebuilt binary instead.
brew install --cask zhaochunqi/tap/git-openDownload the asset for your platform.
macOS (Intel):
curl -L https://github.com/zhaochunqi/git-open/releases/latest/download/git-open_Darwin_x86_64.tar.gz -o git-open.tar.gz
tar -xzf git-open.tar.gz
chmod +x git-open
sudo mv git-open /usr/local/bin/macOS (Apple Silicon):
curl -L https://github.com/zhaochunqi/git-open/releases/latest/download/git-open_Darwin_arm64.tar.gz -o git-open.tar.gz
tar -xzf git-open.tar.gz
chmod +x git-open
sudo mv git-open /usr/local/bin/Linux (x86_64):
curl -L https://github.com/zhaochunqi/git-open/releases/latest/download/git-open_Linux_x86_64.tar.gz -o git-open.tar.gz
tar -xzf git-open.tar.gz
chmod +x git-open
sudo mv git-open /usr/local/bin/Linux (arm64):
curl -L https://github.com/zhaochunqi/git-open/releases/latest/download/git-open_Linux_arm64.tar.gz -o git-open.tar.gz
tar -xzf git-open.tar.gz
chmod +x git-open
sudo mv git-open /usr/local/bin/On Windows, download the zip from the same release and add the extracted folder to
your PATH:
Invoke-WebRequest -Uri https://github.com/zhaochunqi/git-open/releases/latest/download/git-open_Windows_x86_64.zip -OutFile git-open.zip
Expand-Archive -Path git-open.zip -DestinationPath "$env:LOCALAPPDATA\git-open"
# then add %LOCALAPPDATA%\git-open to your PATHAsset names always follow git-open_<OS>_<arch>: Darwin_arm64 for Apple Silicon,
Linux_arm64 for arm64 Linux, Windows_arm64 for Windows on ARM.
WSL users install the same Linux binary inside their distribution — there is no separate package. Everything else is handled automatically; see WSL for the details.
Navigate to your project's directory and run the following command:
git-open or git open
This will open your repository in the default web browser.
To print the repository name (e.g. github.com/zhaochunqi/git-open):
git-open repo
To run as if started in a different directory (e.g. from a script that isn't inside the repo):
git-open -C /path/to/repo repo
The -C flag mirrors git -C: it may be given multiple times, and a non-absolute path is relative to the previous one.
To print the URL instead of opening a browser:
git-open --plain (or -p)
WSL distributions normally have no X server, so xdg-open is not installed. When
running under WSL, git-open tries these openers in order and uses the first one
available:
| Order | Opener | Notes |
|---|---|---|
| 1 | xdg-open |
used when WSLg provides it, so your Linux default browser wins |
| 2 | wslview |
the wslu package, optional |
| 3 | explorer.exe |
Windows default browser, no extra setup needed |
| 4 | powershell.exe |
URL passed as a PowerShell single-quoted literal |
| 5 | cmd.exe |
URL passed as a quoted argument to start |
WSL is detected from WSL_DISTRO_NAME / WSL_INTEROP; when neither is set, the
kernel string in /proc/version is checked for microsoft, which both WSL1 and WSL2
report. Everything else is ordinary Linux behaviour, so installing the Linux binary
is all the setup required.
If none of the openers is available, git-open fails with a pointer to the fix:
install wslu (sudo apt install wslu), enable Windows executable interop, or
configure a browser explicitly (see Configuration):
browser: wslviewA full Windows path works too, which is useful when you want a browser other than the Windows default one:
browser: /mnt/c/Program Files/Google/Chrome/Application/chrome.exegit-open reads the first file that exists, in this order (following the
XDG Base Directory specification):
- the path given to
--config— always wins when passed $XDG_CONFIG_HOME/git-open/config.yaml— i.e.~/.config/git-open/config.yamlwhenXDG_CONFIG_HOMEis not set~/.git-open.yaml— the legacy location, still supported
# Command used to open the URL, executed with the URL as its only argument.
browser: explorer.exeThe BROWSER environment variable is honoured as well, so a one-off override needs no
config file:
BROWSER=wslview git openWhen browser is set it takes precedence over the platform defaults listed in
Platform Support, which makes it the escape hatch for any
platform-specific behaviour.
Branch links are chosen by the remote's hostname. The recognised hosts and the style
each one maps to are listed under Hosts and branch URLs. To
support a host that is not recognised — GitHub Enterprise, Azure DevOps Server, or a
self-hosted instance on a neutral domain such as git.example.com — map its exact
hostname (not the whole remote URL) to a style:
hosts:
git.internal.example: gitea
gitlab.internal.example:
style: gitlab
legacy.example.com: none # repository root onlyA raw template works too — any value containing {branch} is used verbatim — and the
nested object also accepts a branch key, which wins over style:
hosts:
custom.example.com: "/-/tree/{branch}"
other.example.com:
branch: "/src/branch/{branch}"If most of your instances run the same software, set default_style once. It applies
only to hosts with no built-in rule and no override, so the services in the table keep
their own path:
default_style: giteaA misspelled style is an error rather than being silently ignored: git open fails with
a message listing the known styles. --version and help still work, so a broken config
never locks you out of the CLI.
This project follows Go testing best practices. Here's how to run the tests:
# Run all tests
go test ./...
# Run tests with coverage
go test -cover ./...
# Run benchmark tests
go test -bench=. ./...The tests are organized as follows:
- Unit tests for core functionality
- Integration tests for git repository operations
- Benchmark tests for performance-critical functions
The test suite uses a custom test utility package (internal/testhelper) that provides common testing functions and fixtures.
We aim to maintain high test coverage with:
- Multiple test cases for each function
- Edge case testing
- Error condition testing
- Performance benchmarking for critical paths
When adding new features, please ensure:
- Add corresponding test cases
- Include both positive and negative test scenarios
- Add benchmark tests for performance-sensitive functions
- Use the provided test utilities from
internal/testhelper
Contributions are welcome! If you have any suggestions, improvements, or bug fixes, please submit a pull request. For major changes, please open an issue first to discuss what you would like to change.