sync-branches

Syncs a feature branch up through develop and main using fast-forward-only merges and pushes.

1|Updated Aug 6, 2025
One-click install
npx skills add https://github.com/azaidrahman/zaid-sani-dotfiles --skill sync-branches-azaidrahman
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: sync-branches
Source: https://github.com/azaidrahman/zaid-sani-dotfiles/tree/main/dot_claude/skills/sync-branches
Command: npx skills add https://github.com/azaidrahman/zaid-sani-dotfiles --skill sync-branches-azaidrahman

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes scripts (resource) components.

What problem does it solve? Promoting a finished feature branch through a branch hierarchy (feat -> develop -> main) involves repetitive git commands and risks mistakes like merging diverged branches, pushing with a dirty tree, or skipping review before touching main. This Skill automates that promotion flow with a deterministic preflight check and built-in safety gates. ## Core Features & Use Cases - Preflight Feasibility Check: A read-only script fetches refs and reports, per target branch, whether a fast-forward-only merge is possible and how many commits would move, exiting with distinct codes for dirty trees, detached HEAD, or diverged branches. - Flexible Sync Chains: Sync only to develop by default, run a full feat -> develop -> main promotion, or target any specific branch. - Main-Branch Confirmation Gate: Before merging into main, the Skill shows the commit differences in both directions and waits for explicit user confirmation. - Use Case: After finishing a feature, ask to sync your branch; the Skill pushes the feature branch, fast-forwards develop, and—only after you confirm—promotes the changes to main, then returns you to your feature branch. ## Quick Start Ask the assistant to sync my current feature branch up to develop, or say "full sync to main" to promote it through the entire branch chain.

Frequently Asked Questions about sync-branches

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I sync a feature branch to develop and main in git?

Push the feature branch, then for each target run git checkout, git pull --ff-only, git merge --ff-only from the previous branch, and git push. This Skill automates that sequence and adds a preflight check plus a confirmation step before touching main.

How to check if a fast-forward merge is possible before merging?

Use git merge-base --is-ancestor to test whether the target branch is an ancestor of the source branch. The included preflight script does this for every target in the chain and reports how many commits would move.

What happens when branches have diverged during a sync?

The preflight exits with code 5 and reports how far ahead and behind each branch is. The Skill stops and tells you to rebase the feature branch onto the target first; it never auto-resolves divergence or force pushes.

Can I sync only part of the branch chain, like feat to develop only?

Yes. The default target is develop, so a plain sync request promotes feat to develop only. Passing main or saying "full sync" extends the chain to feat -> develop -> main, and any specific branch can be named as the target.

Why does the sync stop with a dirty working tree error?

The preflight refuses to run when git status shows uncommitted changes, exiting with code 2. Commit or stash your changes first so checkouts and merges cannot clobber local work.