gh url takes a branch, tag, or commit ref and outputs the corresponding GitHub URL. It copies the result to your clipboard by default.
gh extension install iloveitaly/gh-urlFor local development:
git clone https://github.com/iloveitaly/gh-url
cd gh-url
gh extension install .gh url [ref] [--no-clip] [--open]ref can be a branch, tag, or commit SHA. Defaults to HEAD.
gh url # current HEAD
gh url main # branch
gh url v1.2.3 # tag
gh url abc1234 # commit- Outputs the appropriate URL based on ref type:
- Branch →
.../tree/<branch> - Tag →
.../releases/tag/<tag> - Commit →
.../commit/<sha>
- Branch →
- Copies the URL to the clipboard automatically (macOS and Linux)
--no-clipto skip clipboard copy--opento open the URL in your browser- Handles both SSH and HTTPS remote URLs
- gh-pr-url — generate a URL for a pull request
- gh-repo-url — generate a URL for a repository
- gh-compare — generate a comparison URL between two refs