sync-default-branch-and-clean

Synchronize the local default branch with its remote and remove obsolete branches.

1|Updated Jun 8, 2025
One-click install
npx skills add https://github.com/ryosukesuto/dotfiles --skill sync-default-branch-and-clean
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: sync-default-branch-and-clean
Source: https://github.com/ryosukesuto/dotfiles/tree/main/config/claude/skills/sync-default-branch-and-clean
Command: npx skills add https://github.com/ryosukesuto/dotfiles --skill sync-default-branch-and-clean

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes scripts (resource) components.

What problem does it solve?

This Skill automates the process of updating your local default branch (like main or master) to match the remote and cleans up old, merged, or orphaned local branches, keeping your repository tidy and up-to-date.

Core Features & Use Cases

  • Default Branch Synchronization: Fetches the latest changes from the remote and rebases your local default branch.
  • Local Branch Cleanup: Identifies and removes local branches that have been merged into the default branch or are no longer present on the remote.
  • Worktree Management: Safely handles and cleans up associated worktrees for merged branches.
  • Use Case: After a period of active development with multiple feature branches, run this Skill to quickly bring your main branch up-to-date and remove all the now-obsolete feature branches, preventing clutter and potential merge conflicts later.

Quick Start

Run the sync-default-branch-and-clean skill to update your default branch and remove merged local branches.

Frequently Asked Questions about sync-default-branch-and-clean

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

FAQPage Schema
How do I sync my local Git default branch with the remote repository?

To sync your local Git default branch, you need to fetch the latest changes from the remote and rebase your local branch. This Skill automates that synchronization process, detecting the default branch name and applying updates safely.

What is the best way to clean up merged local Git branches?

The best way to clean up merged local Git branches is to identify and remove branches that have been merged into the default branch or are no longer present on the remote. This Skill automates that removal to prevent repository clutter.

How do I remove obsolete Git branches that are no longer on the remote?

You can remove obsolete Git branches that are no longer on the remote by purging local branches marked as 'gone'. This Skill safely detects and removes those orphaned local branches during repository synchronization.

Does this branch cleanup tool work with Git worktrees?

Yes, this branch cleanup tool works with Git worktrees. It safely handles and cleans up associated worktrees for merged branches, ensuring a clean and up-to-date local repository state even in complex worktree environments.

Why does my Git branch sync fail due to lock contention?

Git branch sync fails due to lock contention when another Git process holds a lock file. This Skill handles Git lock contention automatically, allowing the synchronization and cleanup process to proceed without manual intervention.

When should I run a local repository cleanup to sync the default branch?

You should run a local repository cleanup to sync the default branch after a period of active development with multiple feature branches. This updates your main branch and removes obsolete branches, preventing clutter and potential merge conflicts.