npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

github-sync

v1.0.4

Published

Sync current or child git repositories and batch delete GitHub repositories with gh.

Downloads

96

Readme

github-sync

Sync the current git repository or local child git repositories to same-name GitHub repositories, and batch delete remote repositories by gh repo list filters.

cd /path/to/parent-folder
npx github-sync
cd /path/to/single-repo
npx github-sync
npx github-sync delete-remote --fork --language JavaScript
npx github-sync delete-remote --fork --language JavaScript --dry-run

Options

github-sync [--include NAME] [--exclude NAME]
github-sync delete-remote [--fork] [--language LANGUAGE] [--include NAME] [--exclude NAME] [--dry-run] [--yes]
  • -i, --include NAME: only sync a direct child directory by name. Repeatable.
  • -e, --exclude NAME: skip a direct child directory by name. Repeatable.
  • delete-remote --fork: delete only fork repositories owned by the target owner.
  • delete-remote -l, --language LANGUAGE: delete only repositories whose primary language matches LANGUAGE.
  • delete-remote -i, --include NAME: only delete a repository by name. Repeatable.
  • delete-remote -e, --exclude NAME: skip a repository by name. Repeatable.
  • delete-remote --dry-run: print matched repositories without deleting them.
  • delete-remote --yes: pass --yes to each gh repo delete call.

delete-remote requires at least one filter, either --fork or --language, so an unfiltered owner-wide delete cannot run by accident.

Sync --include and --exclude apply only in child-repository mode. If the current directory is itself an independent git repository, github-sync syncs the current repository. In delete-remote mode, --include and --exclude filter matched remote repositories by repository name.

Why Not Plain gh?

gh already provides the primitives: gh repo list can filter repositories, and gh repo delete can delete one repository. github-sync combines those steps into a safer batch workflow:

  1. Uses gh repo list with the supported filters, currently --fork and --language.
  2. Supports repeated --include and --exclude name filters on top of the gh repo list result.
  3. Prints the exact matched repository list before deletion starts.
  4. Supports --dry-run to audit the matched list without deleting anything.
  5. Deletes every matched repository by calling gh repo delete for each one.
  6. Refuses to run remote deletion without a filter.
  7. Uses the active gh account as the GitHub owner for sync and cleanup.

This is useful when cleaning generated forks, experiments, or language-specific scratch repositories where deleting one repo at a time through gh is tedious.

For syncing, github-sync also wraps the common local workflow around gh:

  1. Uses gh repo create --source --remote when a matching GitHub repository does not exist yet.
  2. Uses gh repo view --json url to resolve the HTTPS remote URL instead of constructing GitHub URLs manually or using SSH.
  3. Uses gh repo sync for remote-to-local fast-forwards when branch names match.
  4. Keeps git only for local repository operations that gh repo does not replace: checking the worktree, committing local changes, comparing branch ancestry, pushing local commits, and applying local fast-forwards.

Behavior

When the current directory is an independent git repository, github-sync:

  1. Commits local changes so the worktree is clean.
  2. Ensures a same-name GitHub repository exists.
  3. Adds or updates the configured remote for the current repository.
  4. Syncs local and remote when one side can fast-forward the other.
  5. Skips syncing if local and remote histories diverge.

When the current directory is not an independent git repository, github-sync checks each direct child directory:

  1. Skips the child if it is not an independent git repository.
  2. Commits local changes so the worktree is clean.
  3. Ensures a same-name GitHub repository exists.
  4. Uses gh repo sync for remote-to-local fast-forwards when local and remote branch names match.
  5. Falls back to git for branch creation, local-to-remote pushes, branch-name mismatches, or when gh repo sync cannot complete the sync.
  6. Skips that child directory if local and remote histories diverge.

Prerequisites: git, gh, find, realpath, and sort.