Open your git repository in the browser at the current branch and directory. Simple, fast, and works with any git platform.
- 🚀 Opens the browser at the exact location (branch + directory/file)
- 📁 Open specific files: Pass a file path as argument
- 🔢 Line numbers: Jump to specific line or line range in files
- 🔀 Multiple remotes: Choose which remote to open (origin, upstream, fork, etc.)
- 📋 Clipboard mode: Copy URL instead of opening browser
- 🖨️ Print mode: Print the URL to stdout for scripting, no browser or clipboard (takes precedence over
--copy) - 🔖 Commit links: Open a specific commit page or file at a given commit
- 🐚 Shell completion: Built-in completion for bash, zsh, and fish
- 🔄 Converts git:// and ssh:// URLs to HTTPS automatically
- 🌐 Supports GitHub, GitLab, Bitbucket, Azure DevOps, Gitea, Gogs, AWS CodeCommit
- 💻 Cross-platform (macOS, Linux, Windows)
- ⚡ Zero dependencies
# Build and install to /usr/local/bin
cd /path/to/gopen
make build
sudo mv gopen /usr/local/bin/brew install pixibixi/tap/gopenThe tap ships a cask, which Homebrew only supports on macOS. On Linux, use the
pre-built binary, go install, or the container image below.
Download the latest release from the releases page.
docker run --rm -v $(pwd):/repo -w /repo ghcr.io/pixibixi/gopen:latestImages are available for linux/amd64 and linux/arm64 (covers macOS Apple Silicon via Docker Desktop).
git clone https://github.com/pixibixi/gopen.git
cd gopen
make build# Open current directory in browser
gopen
# Open a specific file
gopen main.go
gopen src/components/App.tsx
# Open a specific directory
gopen docs/# Use a different remote (e.g., upstream, fork)
gopen -r upstream
gopen --remote fork
# Copy URL to clipboard instead of opening
gopen -c
gopen --copy
# Print URL to stdout instead of opening (scripting)
gopen -p
gopen --print main.go
# -p wins over -c: this prints the URL, it does not touch the clipboard
gopen -p -c main.go
# Open file at specific line (all syntaxes work)
gopen -l 42 main.go
gopen main.go -l42
gopen --line 100 src/lib/utils.go
# Open file at line range
gopen -l 42-50 main.go
gopen main.go -l 42-50
gopen --line 100-120 src/lib/utils.go
# Combine options
gopen -r upstream -c main.go
gopen --copy src/lib/utils.go
gopen -l 42 -c main.go
# Open a specific commit
gopen --commit abc1234
gopen --commit abc1234 main.go # file at that commit
# Shell completion
gopen --completion # auto-detect shell
gopen --completion=zsh # explicit shell (bash, zsh, fish)
# Show version
gopen -v
gopen --versioncd ~/projects/my-repo
gopen
# → Opens: https://github.com/user/my-repo/tree/maingopen CHANGELOG.md
# → Opens: https://github.com/user/my-repo/tree/main/CHANGELOG.md# Open upstream repository instead of origin
gopen -r upstream
# → Opens: https://github.com/original/repo/tree/maingopen -c src/main.go
# → Output: URL copied to clipboard: https://github.com/user/repo/tree/main/src/main.gogopen -p src/main.go
# → Output: https://github.com/user/repo/tree/main/src/main.go
# Useful in pipelines, e.g. open in a specific browser:
open -a "Google Chrome" "$(gopen -p)"cd ~/projects/my-repo/src/components
git checkout feature/new-component
gopen
# → Opens: https://github.com/user/my-repo/tree/feature/new-component/src/componentscd ~/projects/my-repo/docs
gopen ../src/components/App.tsx
# → Opens: https://github.com/user/my-repo/tree/main/src/components/App.tsx# Open file at specific line (flexible syntax)
gopen -l 42 main.go
gopen main.go -l42
# → Opens: https://github.com/user/my-repo/tree/main/main.go#L42
# Open file at line range
gopen -l 100-120 src/utils.go
gopen src/utils.go -l 100-120
# → Opens: https://github.com/user/my-repo/tree/main/src/utils.go#L100-L120# Open the commit page
gopen --commit abc1234
# → Opens: https://github.com/user/repo/commit/abc1234
# Open a file as it was at a specific commit
gopen --commit abc1234 main.go
# → Opens: https://github.com/user/repo/blob/abc1234/main.go
# Copy commit URL to clipboard
gopen --commit abc1234 -cAdd to your git config for native-style usage:
git config --global alias.open '!gopen'Then use it like:
git open
git open main.go
git open -l 42 main.go
git open -r upstream# zsh — add to ~/.zshrc
eval "$(gopen --completion=zsh)"
# bash — add to ~/.bashrc
eval "$(gopen --completion=bash)"
# fish — add to ~/.config/fish/config.fish
gopen --completion=fish | sourceAfter reloading your shell, gopen --<Tab> completes flags and gopen <Tab> completes file paths.
| Platform | URL Pattern |
|---|---|
| GitHub | https://github.com/user/repo/tree/branch/path |
| GitLab | https://gitlab.com/user/repo/-/tree/branch/path |
| Bitbucket Cloud | https://bitbucket.org/user/repo/src/branch/path |
| Azure DevOps | https://dev.azure.com/org/project/_git/repo?version=GBbranch&path=/path |
| Gitea | https://gitea.domain.com/user/repo/src/branch/path |
| Gogs | https://gogs.domain.com/user/repo/src/branch/path |
| AWS CodeCommit | Console URLs with branch and path |
| Others | Falls back to GitHub-style format |
All git URL formats are automatically converted to HTTPS:
git@github.com:user/repo.git → https://github.com/user/repo
ssh://git@github.com/user/repo.git → https://github.com/user/repo
git://github.com/user/repo.git → https://github.com/user/repo
https://github.com/user/repo.git → https://github.com/user/repogopen reads .git directly (config, HEAD, worktree layout) instead of shelling out to git, which makes most runs faster. It falls back to invoking the git binary whenever it cannot be certain — a config include or insteadOf rewrite it would have to resolve, a worktree config, custom ref storage, a symlinked HEAD, and similar. The fast path is designed to refuse rather than guess: erring towards a fallback costs a few milliseconds, whereas answering differently from git would send you to the wrong page.
Two known gaps are documented in the source and fall outside that guarantee: the system-wide config path is compiled into the git binary and can only be guessed (the standard locations and the one implied by git on PATH are covered), and the discovery walk does not stop at a filesystem boundary the way git does without GIT_DISCOVERY_ACROSS_FILESYSTEM.
- Git installed and in PATH
- Go 1.27+ (for building from source)
- macOS: 13 Ventura or later — Go 1.27 dropped support for earlier releases
- Linux clipboard feature:
wl-copy(Wayland),xclip, orxsel
# Build
go build -o gopen .
# Test
go test ./...
# Lint
go vet ./...
staticcheck ./...Releases are cut automatically from Conventional Commits:
- Push (or merge) commits to
main—feat:bumps the minor,fix:the patch, a breaking change the minor while the project is still0.x. Every other type (chore:,docs:,ci:,perf:,refactor:,test:) releases nothing, so mark a change withfix:if it needs to ship on its own - The
Releaseworkflow computes the nextvX.Y.Zand creates the tag - In the same run, GoReleaser builds the binaries for all platforms and updates the Homebrew tap
Pushing a v* tag by hand still triggers the same release path.
MIT
