gh-compare

command module
v1.0.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 13, 2026 License: MIT Imports: 9 Imported by: 0

README

gh-compare

A gh CLI extension that opens GitHub's compare view in your browser. It detects forks, resolves your repository's default branch automatically, and supports branch and commit comparisons.

This was built to replace the compare command from the deprecated hub tool.

Installation

gh extension install wassimk/gh-compare

Usage

The command must be run inside a git repository with a GitHub remote.

Compare the current branch against the repository's default branch.

gh compare

Compare the current branch against another branch.

gh compare other_branch

Compare any two branches using ... (three-dot) notation. This shows only the changes introduced by the second branch, like a pull request diff. Commits added to the first branch after the two diverged are ignored.

gh compare main...my_branch

You can also use .. (two-dot) notation for a direct diff between two branches as they exist right now. Unlike three-dot, this includes the effect of commits on both sides.

gh compare main..my_branch

Compare any two commits.

gh compare 7a67154..205b073

Forks

If your repository is a fork with an upstream remote, gh compare automatically generates a cross-fork compare URL. For example, running gh compare on a fork will produce a URL like:

https://github.com/upstream-owner/repo/compare/main...your-user:your-branch

This matches GitHub's compare-across-forks behavior so the diff is shown against the upstream repository.

Upgrade / Uninstall

gh extension upgrade wassimk/gh-compare
gh extension remove gh-compare

Documentation

The Go Gopher

There is no documentation for this package.

Directories

Path Synopsis
internal
clipboard
Package clipboard provides platform-aware clipboard write support.
Package clipboard provides platform-aware clipboard write support.
git
Package git provides Git repository operations and types for the gh-compare CLI extension.
Package git provides Git repository operations and types for the gh-compare CLI extension.
github
Package github provides GitHub-specific functionality for generating compare URLs.
Package github provides GitHub-specific functionality for generating compare URLs.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL