GitHub CLI Extension to sync your fork with its upstream repository.
Features
Automatically detects the parent repository
Adds upstream remote if not present
Fetches and merges the latest changes from upstream
Pushes the changes to your fork
Colored output for better visibility
Installation
gh extension install him0/gh-sync
Usage
gh sync
This will:
Check if the current directory is a git repository
Get the parent repository information
Add upstream remote if not present
Fetch from upstream
Merge upstream's default branch (main/master) into your current branch
Push to origin
Example
$ cd my-forked-repo
$ gh sync
Parent repository: original-owner/original-repo
Upstream already configured: https://github.com/original-owner/original-repo.git
Fetching from upstream...
Default branch: main
Merging upstream/main...
Pushing to origin...
✓ Successfully synced with upstream
Requirements
GitHub CLI (gh) must be installed and authenticated
Git must be installed
The current directory must be a git repository that is a fork
Notes
The extension will warn you if you're not on the main/master branch
If merge conflicts occur, you'll need to resolve them manually
The extension uses the default branch of the upstream repository (main or master)
Acknowledgments
This project is inspired by hub's sync command. While hub provides a comprehensive set of GitHub CLI features, gh-sync focuses solely on the fork synchronization functionality as a standalone GitHub CLI extension.