Skip to content

AIRiskGuy/gh-org-repo-sync

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 

Repository files navigation

gh-org-repo-sync

A GitHub CLI extension that syncs all repositories between a GitHub organization and a local directory.

Why?

When you manage multiple repos under a GitHub org, keeping your local workspace in sync becomes tedious. This extension:

  • Detects which repos exist remotely, locally, or both
  • Syncs repos that exist in both places (git pull --ff-only)
  • Clones repos that only exist remotely (with confirmation)
  • Creates & pushes repos that only exist locally (with confirmation)
  • Matches renamed folders by checking remote URLs (e.g., local my-app/ pointing to org/my-application)

Installation

gh extension install crankd/gh-org-repo-sync

Usage

# Interactive mode — prompts before clone/push actions
gh org-repo-sync --org <org> --dir <path>

# Preview what would happen
gh org-repo-sync --org <org> --dir <path> --dry-run

# Auto-approve all actions
gh org-repo-sync --org <org> --dir <path> --yes

Flags

Flag Description Default
--org <org> GitHub organization name required
--dir <path> Local directory containing repos current directory
--dry-run Show plan without executing false
--yes Skip confirmation prompts false
-h, --help Show help message

Example output

═══════════════════════════════════════════════════
  Org Repo Sync: my-org ↔ /Users/me/projects/my-org
═══════════════════════════════════════════════════

SYNC (pull latest)
  ● api-server
  ● web-app
  ● local-name → remote-name

CLONE (remote → local)
  ● my-org/new-service

PUSH (local → new remote)
  ● my-local-tool

Total: 3 sync, 1 clone, 1 push (5 repos)

How matching works

  1. Exact name match — local folder name equals remote repo name
  2. Remote URL match — if the local folder's origin remote URL contains the org repo name (handles renamed local folders)

Behavior details

  • SYNC runs automatically (fast-forward pull only, safe operation)
  • CLONE and PUSH prompt individually unless --yes is passed
  • New repos are created as private by default
  • For PUSH, the local remote URL is updated to point to the new org repo
  • Non-git directories and hidden directories are skipped

Requirements

  • GitHub CLI (gh) v2.0+
  • git
  • python3 (for JSON parsing)
  • Authenticated with gh auth login

License

MIT

About

gh CLI extension: sync all repos between a GitHub org and a local directory

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages