Skip to content

wassimk/gh-sync

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

gh-sync

A gh CLI extension that keeps local branches in sync with a remote. It fetches, fast-forwards outdated branches, warns about unpushed work, and cleans up branches whose upstream was deleted after merging (including squash merges).

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

🛠️ Installation

gh extension install wassimk/gh-sync

💻 Usage

Run inside any git repository:

gh sync

That's it. The command will:

  1. Find the primary remote (upstream > github > origin)
  2. Fetch with pruning
  3. For each local branch:
    • Fast-forward if the branch is behind its remote counterpart
    • Warn if the branch has unpushed commits
    • Delete if the upstream was removed and the branch was merged (or squash-merged) into the default branch
    • Warn if the upstream was removed but the branch appears unmerged

Branches without explicit tracking configuration are matched by name against the remote.

⚙️ Flags

--verbose, -v     Log each git command to stderr

📝 Examples

Fast-forward a branch that fell behind:

Updated branch feature-login (was 3a1b2c4).

Warn about local work that hasn't been pushed:

warning: 'experiment' seems to contain unpushed commits

Clean up a merged branch whose remote was deleted:

Deleted branch add-user-api (was 7f8e9d0).

📦 Upgrade / Uninstall

gh extension upgrade wassimk/gh-sync
gh extension remove gh-sync

🙏 Attribution

Inspired by jacobwgillespie/git-sync, rebuilt as a gh CLI extension.

About

A gh CLI extension to sync local branches with their remote counterparts

Topics

Resources

License

Stars

Watchers

Forks

Contributors

Languages