OpenParable
Skip to content
← Back to skills

worktree-sync

Development

Sync git worktrees with remote and main branch changes. Use to keep long-running feature branches up-to-date.

View on GitHub ↗
QUICK START

How to use this skill

Bring this guide into your coding agent with a prompt tailored to the tool you use.

  1. Open your project in Codex.
  2. Copy and paste the prompt below.
  3. Review files and risks before approving any action.
Prompt to paste
Inspect the Agent Skill at https://github.com/majiayu000/claude-skill-registry/blob/HEAD/skills/data/worktree-sync/SKILL.md and all supporting files. Report provenance, permissions, scripts, dependencies, and security risks. Propose an exact installation into .agents/skills/worktree-sync, but wait for my approval before writing files or running scripts.

Copying this prompt does not install or run the skill. Review third-party files before use.

Worktree Sync

Keep worktrees synchronized with remote changes.

When to Use

  • Long-running feature branches
  • Main branch has new commits
  • Before creating/updating PR
  • Resolving merge conflicts
  • Feature branch is diverged from main

Quick Reference

# Fetch latest from remote (works in any worktree)
git fetch origin

# Update main worktree
cd ../ProjectOdyssey && git pull origin main

# Update feature worktree (rebase approach)
cd ../ProjectOdyssey-42-feature && git rebase origin/main

# Update feature worktree (merge approach)
cd ../ProjectOdyssey-42-feature && git merge origin/main

# Auto-sync all worktrees
./scripts/sync_all_worktrees.sh

Workflow

  1. Fetch remote - git fetch origin (any worktree)
  2. Update main - Navigate to main worktree, git pull origin main
  3. Update feature - Navigate to feature worktree, git rebase origin/main or git merge
  4. Resolve conflicts - If conflicts occur, fix files and git rebase --continue
  5. Verify - Check git log to confirm main branch changes are included

Rebase vs Merge

ApproachUse WhenCommand
RebaseLinear history preferredgit rebase origin/main
MergePreserving branch historygit merge origin/main

Error Handling

ErrorSolution
Conflicts during rebaseRun git status, fix files, git add ., git rebase --continue
Diverged branchesUse git pull --rebase origin main
Uncommitted changesCommit or stash before syncing
Detached HEADCheck git status and git checkout <branch>

Conflict Resolution

# If conflicts occur
git status  # See conflicted files

# Edit files to resolve conflicts
# Then continue
git add .
git rebase --continue

# Or abort if something went wrong
git rebase --abort

Best Practices

  • Fetch regularly to catch conflicts early
  • Sync before creating PR to avoid merge conflicts
  • Keep feature branches short-lived (2-3 days max)
  • Resolve conflicts immediately
  • Use rebase for linear history (preferred for this project)

References