Skip to content

yonasBSD/branch-watch

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

33 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

branch-watch — GitHub Branch & Fork Sync Status CLI

GitHub Marketplace Release PyPI npm License: MIT

If you find this useful, consider leaving a ⭐ — it helps others discover the project.

branch-watch demo

branch-watch (bw) is a fast, single-binary CLI tool that tells you — at a glance — whether your GitHub branches are behind main, how far your forks have drifted from upstream, and what pull requests are open. No browser required. Powered by the GitHub REST API.

TL;DR — Run bw forks to see all your forked repos vs. upstream. Run bw branches owner/repo to see every branch vs. the default branch. Run bw prs owner/repo for open PRs.


Why branch-watch?

Keeping track of GitHub branch and fork sync status manually is tedious:

  • You maintain multiple forks of open-source projects and need to know which ones are stale
  • Your team has dozens of feature branches and you want to catch the ones that have drifted before they become impossible to merge
  • You want to check open PR status without leaving the terminal

branch-watch solves all three with a single command.


What's New in v0.3.0

  • Parallel API calls — fork and branch comparisons now run concurrently; dramatically faster on large repos
  • Paginationbw forks now fetches all forks even if you have more than 100
  • bw branches --base <branch> — compare branches against any branch, not just the default
  • bw forks --org <org> — check fork sync status for an entire GitHub organization
  • bw ignore — hide specific repositories from all output with bw ignore add/remove/list

Demo

Check if all your forks are behind upstream

$ bw forks

Forked repositories

  alice/rust          rust-lang/rust        ↓ 42 behind
  alice/tokio         tokio-rs/tokio        ↓ 7 behind   ↑ 2 ahead
  alice/serde         serde-rs/serde        ✓ in sync
  acme/axum           tokio-rs/axum         ↓ 15 behind  ↑ 8 ahead
  acme/reqwest        seanmonstar/reqwest   ↑ 3 ahead

Filter to only stale forks:

$ bw forks --behind-only

Forked repositories

  alice/rust          rust-lang/rust   ↓ 42 behind
  acme/axum           tokio-rs/axum   ↓ 15 behind  ↑ 8 ahead
  alice/tokio         tokio-rs/tokio  ↓ 7 behind   ↑ 2 ahead

Check branch sync status vs. main

$ bw branches owner/repo

→ owner/repo (base: main)

  feature/auth        ↓ 3 behind  ↑ 2 ahead
  feat/dashboard      ↓ 14 behind
  fix/login           ✓ up to date

List open pull requests

$ bw prs owner/repo

→ owner/repo — 2 open PRs

  #101  Add dark mode support
         feat/dark-mode → main  by @alice · 2 reviewers · opened 2026-03-01

  #98   Fix login redirect [draft]
         fix/login → main  by @bob · opened 2026-04-10

Machine-readable JSON output

$ bw branches owner/repo --json | jq '.[] | select(.behind > 10)'
{
  "branch": "feat/dashboard",
  "base": "main",
  "behind": 14,
  "ahead": 0
}

Features

Feature Description
Fork sync status Shows behind/ahead commit count for all your forked repos vs. upstream, sorted by staleness
Branch status Shows every branch vs. the repo's default branch
PR overview Lists open PRs with author, branches, draft status, reviewer count, and open date
--behind-only filter Suppress up-to-date entries; show only what needs attention
--json output Structured JSON for scripting, CI, and jq pipelines
gh CLI auto-detection No bw auth needed if you already use the GitHub CLI
GitHub Actions support Use as a CI step to fail builds on stale branches
Multi-platform macOS (Intel + Apple Silicon), Linux (x86_64 + ARM64)
Single binary No runtime, no dependencies — written in Rust
Ignore list Hide specific repos from all output with bw ignore add
Org support Check fork sync for an entire GitHub org with bw forks --org
Custom base branch Compare branches against any ref, not just the default
Token-based auth Works with GitHub PAT via env var, config file, or gh CLI

Installation

GitHub CLI extension

gh extension install nuri-yoo/gh-branch-watch
gh branch-watch forks

Homebrew — recommended for macOS and Linux

brew install nuri-yoo/tap/branch-watch

pip — for Python users

pip install branch-watch

npm — for Node.js users

npm install -g branch-watch

Pre-built binaries — direct download

Download from the releases page:

Platform Binary
macOS Apple Silicon (M1/M2/M3/M4/M5) branch-watch-*-aarch64-apple-darwin.tar.gz
macOS Intel branch-watch-*-x86_64-apple-darwin.tar.gz
Linux x86_64 branch-watch-*-x86_64-unknown-linux-gnu.tar.gz
Linux ARM64 branch-watch-*-aarch64-unknown-linux-gnu.tar.gz
tar xzf branch-watch-*.tar.gz
sudo mv bw /usr/local/bin/

Build from source — for Rust developers

Requires Rust 1.80+.

git clone https://github.com/nuri-yoo/branch-watch
cd branch-watch
cargo install --path .

Authentication

branch-watch uses the GitHub REST API and requires a Personal Access Token (PAT) with repo scope.

Generate a token: github.com/settings/tokens → Generate new token → select repo

Option 1 — gh CLI auto-detection (zero setup):

If you already have the GitHub CLI installed and logged in, bw picks up your token automatically. No extra configuration needed.

gh auth login   # one-time setup if not already done
bw forks        # works immediately

Option 2 — Save to config file (persistent):

bw auth ghp_xxxxxxxxxxxxxxxxxxxx
# Saved to ~/.branch-watch.toml

Option 3 — Environment variable:

export GITHUB_TOKEN=ghp_xxxxxxxxxxxxxxxxxxxx
bw forks

Token priority: config file → GITHUB_TOKEN env var → gh CLI


Usage

bw forks — check if your GitHub forks are behind upstream

Lists all repositories you have forked and compares each one to its upstream default branch. Results are sorted by how many commits behind, worst first.

bw forks
bw forks --behind-only             # show only stale forks
bw forks --json                    # machine-readable output
bw forks --org <org>               # check forks in an organization
bw forks --org <org> --behind-only # combine flags

When to use: After returning from vacation, before syncing forks, or when maintaining many open-source forks simultaneously.

bw branches — check if branches are behind main

Shows the sync status of every branch in a repository relative to the default branch (usually main or master). Sorted by commits behind, worst first.

bw branches owner/repo
bw branches owner/repo --behind-only
bw branches owner/repo --base develop   # compare against a specific branch
bw branches owner/repo --json

When to use: Before a sprint planning session, during code review, or when cleaning up stale branches.

bw prs — list open pull requests

Lists all open pull requests sorted oldest-first, with author, source → target branch, draft indicator, reviewer count, and open date.

bw prs owner/repo
bw prs owner/repo --json

When to use: Daily standup, PR review sessions, or release preparation.

bw auth — save GitHub token

bw auth <token>

bw ignore — hide repositories from output

Add noisy or irrelevant repositories to an ignore list so they never appear in bw forks or bw branches output.

bw ignore add owner/repo      # hide a repository
bw ignore remove owner/repo   # unhide a repository
bw ignore list                # show all ignored repositories

Use in GitHub Actions

branch-watch is available on the GitHub Marketplace. Add it to any workflow to automatically check branch sync status in CI:

steps:
  - uses: nuri-yoo/branch-watch@v1
    with:
      command: branches          # branches | forks | prs
      repo: ${{ github.repository }}
    env:
      GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

Use cases in CI:

  • Fail a build if feature branches are more than N commits behind main
  • Post a daily Slack summary of fork sync status
  • Block merges when a branch is significantly out of date

Versioning and Releases

branch-watch uses semantic versioning. When a v* tag is pushed, the release workflow automatically:

  1. Builds binaries for all 4 platforms (macOS arm64/x86_64, Linux x86_64/arm64)
  2. Creates a GitHub Release with attached binaries
  3. Publishes to PyPI (pip install branch-watch)
  4. Publishes to npm (npm install -g branch-watch)
  5. Updates the Homebrew formula with correct SHA256 checksums

To release a new version:

git tag v0.3.0
git push origin v0.3.0

Everything else is automated.


FAQ

How do I check if my GitHub fork is behind upstream? Run bw forks. It lists every fork in your GitHub account and shows how many commits it is behind or ahead of the upstream repository.

How do I check if a branch is behind main on GitHub? Run bw branches owner/repo. It compares every branch in the repository against the default branch and shows behind/ahead commit counts.

Do I need to run bw auth if I already use the GitHub CLI? No. If gh is installed and authenticated, branch-watch detects the token automatically. bw auth is only needed if you don't use the GitHub CLI.

Does branch-watch work with private repositories? Yes. Any private repository your GitHub token has repo scope access to will work.

Does branch-watch support GitHub Enterprise Server? Not yet. Currently supports github.com only.

What is the difference between branch-watch and git fetch --prune? git fetch requires a local clone of the repository. branch-watch queries the GitHub API remotely — no local clone needed. It also works across all your repositories at once.

Can I pipe the output to other tools? Yes. Use --json to get structured output and pipe it to jq, grep, or any other tool.

Does branch-watch support GitLab or Bitbucket? No. branch-watch is built specifically for the GitHub REST API.

Is branch-watch free? Yes. branch-watch is open-source under the MIT license.


GitHub API Usage

branch-watch integrates with the following GitHub REST API endpoints:

Method Endpoint Purpose
GET /user/repos?type=fork List authenticated user's forked repositories
GET /orgs/{org}/repos?type=fork List an organization's forked repositories
GET /repos/{owner}/{repo} Fetch repository metadata and upstream parent
GET /repos/{owner}/{repo}/branches List all branches
GET /repos/{owner}/{repo}/compare/{base}...{head} Get ahead/behind commit counts
GET /repos/{owner}/{repo}/pulls?state=open List open pull requests

License

MIT © nuri-yoo

About

Track branch and fork sync status across your GitHub repositories

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors