git-sync

Sync local git branches with remotes via PR-aware rebase workflows.

1|Updated Sep 6, 2024
One-click install
npx skills add https://github.com/carlos18bp/gym_project --skill git-sync-carlos18bp
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: git-sync
Source: https://github.com/carlos18bp/gym_project/tree/main/.agents/skills/git-sync
Command: npx skills add https://github.com/carlos18bp/gym_project --skill git-sync-carlos18bp

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill requires gh, jq, and includes scripts (resource) components.

What problem does it solve?

Keeps a developer’s local branch aligned with the remote by automatically fetching updates and rebasing in a PR-aware way, reducing the risk of stale work and painful manual reconciliation.

Core Features & Use Cases

  • PR-aware rebase target selection: Rebases onto the correct parent branch or onto the open PR’s head when appropriate, instead of rebasing blindly against main/master.
  • Pre-flight safety checks: Detects dirty working trees and warns before proceeding, and inspects stashes for obsoletos/viejos without deleting anything automatically.
  • Guided conflict resolution workflow: When rebase conflicts occur, it provides a structured process to inspect markers, resolve intentionally, and continue or abort the rebase.

Quick Start

Run git-sync from your terminal on the host and repo you want to sync, then follow any prompts if the working tree has pending changes.

Frequently Asked Questions about git-sync

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

FAQPage Schema
How do I rebase my local git branch onto the correct parent when an open pull request changes the target?

To rebase a local git branch safely, the sync process fetches from origin and determines the parent branch using origin/HEAD, optionally detecting open GitHub pull requests via gh CLI to select the correct rebase target automatically. This prevents blindly rebasing against main or master when the PR head differs.

What happens to my uncommitted changes when I sync a dirty working tree?

When syncing a dirty working tree, pre-flight safety checks detect pending changes and warn before proceeding. Stash management inspects for obsolete stashes without deleting anything automatically, ensuring your local modifications remain intact during the fetch and rebase operations.

How do I resolve rebase conflicts after syncing my branch with the remote?

To resolve rebase conflicts, a guided workflow helps you inspect conflict markers, resolve them intentionally, and then continue or abort the rebase. The process provides structured conflict resolution guidance without performing automatic stash drops or force pushes.

Do I need the GitHub CLI and jq to perform a PR-aware branch sync?

Yes, PR-aware branch sync requires the gh CLI authenticated to your GitHub account and jq installed. These dependencies fetch origin updates, determine parent branches from origin/HEAD, and detect open pull requests using JSON output for safe rebase target selection.

Can I use this branch synchronization approach across multiple repositories?

Yes, this branch synchronization applies to both single-repo and multi-repo workflows. It performs origin fetch, determines parent branches from origin/HEAD, and detects open PRs to execute rebase operations with conflict guidance without force pushing across your repositories.

Why does my git rebase fail when there are open pull requests changing the target branch?

Git rebase can fail when blind target selection ignores open pull requests. PR-aware rebase target selection detects open PRs via gh CLI JSON output and rebases onto the PR head when appropriate, avoiding stale work and manual reconciliation against main or master.