git-sync

Sync a feature branch with the default branch via rebase or merge with interactive conflict resolution.

Updated Dec 18, 2025
One-click install
npx skills add https://github.com/l0lxl0lw/dotfiles --skill git-sync-l0lxl0lw
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: git-sync
Source: https://github.com/l0lxl0lw/dotfiles/tree/main/ai/shared/skills/git/git-sync
Command: npx skills add https://github.com/l0lxl0lw/dotfiles --skill git-sync-l0lxl0lw

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes scripts (resource) components.

What problem does it solve? Keeping a long-lived feature branch current with the default branch is error-prone: rebases can rewrite pushed history, conflicts get resolved blindly, and uncommitted work gets lost. This Skill automates the sync while forcing every conflict decision through the user. ## Core Features & Use Cases - Rebase-first strategy with merge fallback: Analyzes the branch and picks a rebase when it is clean, falling back to a merge when the branch is pushed with an open PR, contains merge commits, or conflicts span multiple commits. - Interactive per-block conflict resolution: Walks through every conflict block one at a time, labeling sides as "your branch" vs "main" to avoid the ours/theirs inversion trap between rebase and merge. - Safety rails: Stashes uncommitted work, creates a backup branch before rebasing, verifies no conflict markers survive, and never force-pushes without explicit confirmation. - Use Case: You have been on a feature branch for a week and main has moved 30 commits ahead. Run the sync to rebase cleanly, resolve two conflicts with your input, verify the build still passes, and leave your uncommitted work restored. ## Quick Start Ask the assistant to sync your current feature branch with the latest main, for example by saying "sync my branch with main and walk me through any conflicts".

Frequently Asked Questions about git-sync

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

FAQPage Schema
How do I sync my feature branch with the latest main branch?

Run the sync workflow, which fetches origin, fast-forwards the local default branch by ref, then rebases your feature branch onto origin/main. If a rebase is unsafe, it merges instead and resolves conflicts with you one block at a time.

When should I rebase versus merge main into my branch?

Rebase when your branch is local-only with no merge commits, giving linear history. Merge instead when the branch is pushed with an open PR, already contains merge commits, or when conflicts span multiple commits, since a merge resolves each collision once.

Why are ours and theirs reversed during a git rebase?

During a rebase, git replays your commits onto the default branch, so ours refers to the default branch and theirs refers to your own commit. This is the opposite of a merge, which is why conflicts should always be labeled by concrete side like your branch versus main.

Can I rebase a branch that is already pushed to origin?

Yes, but it requires git push --force-with-lease afterward since rebase rewrites commit SHAs. If the branch has an open PR, merging is recommended instead because force-pushing can orphan review comments pinned to old SHAs.

What happens to my uncommitted changes during a branch sync?

Uncommitted changes are stashed before the sync begins and restored with git stash pop afterward. The stash is never dropped until it applies cleanly or you explicitly confirm, so no work is lost.

Why does a clean merge still break my build?

Git only detects textual conflicts, not semantic ones like renamed functions or changed signatures introduced by the default branch. The workflow runs the repo's build and test commands after syncing to surface these breakages.