मुख्य सामग्री पर जाएँ
Skillpedia
डिप्लॉय और क्लाउड (DevOps)29k · #9588

git-worktree-manager

यह क्या करती है

यह स्किल git प्रोजेक्ट की अतिरिक्त कार्यकारी प्रतियाँ सेट करती है, ताकि एक साथ कई ब्रांच खुली रह सकें। यह उन डेवलपर्स के लिए है जो एक साथ एक से ज़्यादा फ़ीचर पर काम करते हैं। यह अब ज़रूरी न रहीं प्रतियाँ भी सुरक्षित रूप से हटाती है।

कब इस्तेमाल करें

  • ✓जब आपको एक ही प्रोजेक्ट की दो या अधिक ब्रांच एक साथ पर काम करना हो।
  • ✓जब कई AI एजेंट को अलग-अलग ब्रांच पर बिना टकराव के काम करना हो।
  • ✓जब पुरानी कार्यकारी प्रतियाँ जमा हो गई हों और आप उन्हें सुरक्षित रूप से हटाना चाहते हों।

Skill का लिंक

https://github.com/alirezarezvani/claude-skills/blob/main/engineering/skills/git-worktree-manager/SKILL.md

इसे कॉपी करके अपने AI (Claude, ChatGPT या Cursor) में पेस्ट करें और निर्देशों का पालन करने को कहें।

कैसे इस्तेमाल करें

सबसे आसान तरीका: मैसेज कॉपी करके अपने AI में पेस्ट करें। वह skill पढ़कर निर्देशों का पालन करेगा।

पेस्ट करने के लिए तैयार मैसेज

इस skill से मेरी मदद करो: https://github.com/alirezarezvani/claude-skills/blob/main/engineering/skills/git-worktree-manager/SKILL.md इस लिंक की SKILL.md फ़ाइल पढ़ो और मेरे काम में उसके निर्देशों का पालन करो।
क्या आप चाहते हैं कि आपका AI ऐसी skills खुद ढूँढे?मुफ़्त Skillpedia MCP इंस्टॉल करें: बस एक लाइन, और हर काम से पहले यह 15,000+ skills में खोजता है।1 मिनट में इंस्टॉल करें →

AI से क्या माँगें: उदाहरण

“मेरे नए लॉगिन फ़ीचर के लिए इस प्रोजेक्ट की एक अलग कार्यकारी प्रति सेट कीजिए, ताकि मेरी मौजूदा ब्रांच खुली रहे।”

हर हफ़्ते 5 नई skills, 1 मिनट में पढ़ें।

यह कैसे काम करती है

यह स्क्रिप्ट के ज़रिए हर प्रति को अपने फ़ोल्डर में बनाती है, उसे खाली पोर्ट देती है और लोकल एनवायरनमेंट फ़ाइलें कॉपी करती है, फिर किसी सफ़ाई से पहले बिना सहेजे बदलाव जाँचती है।

तकनीकी सामग्री (मूल SKILL.md)

लेखक का मूल टेक्स्ट, अंग्रेज़ी में, सीधे GitHub से।

Git Worktree Manager

Tier: POWERFUL
Category: Engineering
Domain: Parallel Development & Branch Isolation

Overview

Use this skill to run parallel feature work safely with Git worktrees. It standardizes branch isolation, port allocation, environment sync, and cleanup so each worktree behaves like an independent local app without stepping on another branch.

This skill is optimized for multi-agent workflows where each agent or terminal session owns one worktree.

Core Capabilities

  • Create worktrees from new or existing branches with deterministic naming
  • Auto-allocate non-conflicting ports per worktree and persist assignments
  • Copy local environment files (.env*) from main repo to new worktree
  • Optionally install dependencies based on lockfile detection
  • Detect stale worktrees and uncommitted changes before cleanup
  • Identify merged branches and safely remove outdated worktrees

When to Use

  • You need 2+ concurrent branches open locally
  • You want isolated dev servers for feature, hotfix, and PR validation
  • You are working with multiple agents that must not share a branch
  • Your current branch is blocked but you need to ship a quick fix now
  • You want repeatable cleanup instead of ad-hoc rm -rf operations

Key Workflows

1. Create a Fully-Prepared Worktree

  1. Pick a branch name and worktree name.
  2. Run the manager script (creates branch if missing).
  3. Review generated port map.
  4. Start app using allocated ports.
python scripts/worktree_manager.py \
  --repo . \
  --branch feature/new-auth \
  --name wt-auth \
  --base-branch main \
  --install-deps \
  --format text

If you use JSON automation input:

cat config.json | python scripts/worktree_manager.py --format json
# or
python scripts/worktree_manager.py --input config.json --format json

2. Run Parallel Sessions

Recommended convention:

  • Main repo: integration branch (main/develop) on default port
  • Worktree A: feature branch + offset ports
  • Worktree B: hotfix branch + next offset

Each worktree contains .worktree-ports.json with assigned ports.

3. Cleanup with Safety Checks

  1. Scan all worktrees and stale age.
  2. Inspect dirty trees and branch merge status.
  3. Remove only merged + clean worktrees, or force explicitly.
python scripts/worktree_cleanup.py --repo . --stale-days 14 --format text
python scripts/worktree_cleanup.py --repo . --remove-merged --format text

4. Docker Compose Pattern

Use per-worktree override files mapped from allocated ports. The script outputs a deterministic port map; apply it to docker-compose.worktree.yml.

See docker-compose-patterns.md for concrete templates.

5. Port Allocation Strategy

Default strategy is base + (index * stride) with collision checks:

  • App: 3000
  • Postgres: 5432
  • Redis: 6379
  • Stride: 10

See port-allocation-strategy.md for the full strategy and edge cases.

Script Interfaces

  • python scripts/worktree_manager.py --help
    • Create/list worktrees
    • Allocate/persist ports
    • Copy .env* files
    • Optional dependency installation
  • python scripts/worktree_cleanup.py --help
    • Stale detection by age
    • Dirty-state detection
    • Merged-branch detection
    • Optional safe removal

Both tools support stdin JSON and --input file mode for automation pipelines.

Common Pitfalls

  1. Creating worktrees inside the main repo directory
  2. Reusing localhost:3000 across all branches
  3. Sharing one database URL across isolated feature branches
  4. Removing a worktree with uncommitted changes
  5. Forgetting to prune old metadata after branch deletion
  6. Assuming merged status without checking against the target branch

Best Practices

  1. One branch per worktree, one agent per worktree.
  2. Keep worktrees short-lived; remove after merge.
  3. Use a deterministic naming pattern (wt-<topic>).
  4. Persist port mappings in file, not memory or terminal notes.
  5. Run cleanup scan weekly in active repos.
  6. Use --format json for machine flows and --format text for human review.
  7. Never force-remove dirty worktrees unless changes are intentionally discarded.

Validation Checklist

Before claiming setup complete:

  1. git worktree list shows expected path + branch.
  2. .worktree-ports.json exists and contains unique ports.
  3. .env files copied successfully (if present in source repo).
  4. Dependency ins
अक्सर पूछे जाने वाले सवाल

क्या यह मेरा बिना सहेजा काम मिटा देगी?

सफ़ाई के कदम से पहले यह बिना कमिट बदलाव जाँचता है, इसलिए काम खोने से बचाने के लिए बनाया गया है।

क्या हर प्रति अपने पोर्ट पर चलती है?

हाँ, स्किल हर कार्यकारी प्रति को पोर्ट देती है, ताकि दो dev server आपस में न टकराएँ।

क्या यह मेरी लोकल सेटिंग फ़ाइलें कॉपी करती है?

हाँ, यह मुख्य प्रोजेक्ट की लोकल एनवायरनमेंट फ़ाइलें नई कार्यकारी प्रति में कॉपी करती है।

जानकारी

लेखक का मूल विवरण

Use when running several branches or agents in parallel on one repo. Creates worktrees with isolated ports and env via worktree_manager.py and removes stale ones with worktree_cleanup.py.

repo: alirezarezvani/claude-skills

लोकप्रियता

GitHub स्टार
29k
रैंकिंग में स्थान
#9588
लाइसेंस
MIT
अपडेट की गई
2/11/2026

क्या यह skill काम की है?

0

लॉग इन करें वोट करने के लिए।

कमेंट

  • …

इस repository की और skills

agent-launcher-orchestrator

29k

आपके एजेंट को एक साफ़ लक्ष्य से शुरू करके, अपने खाते में Claude मैनेज्ड एजेंट की योजना बनाने, बनाने, जांचने और शेड्यूल करने में चरण-दर-चरण मदद करती है।

AI और एजेंटएजेंट

grade-iterate

29k

आपके एजेंट को किसी मैनेज्ड AI एजेंट के काम को रूब्रिक से आंकने और तय संख्या के दौरों में सुधारने देती है, ताकि वह कभी अनंत चक्र में न फंसे।

AI और एजेंटएजेंट

interview

29k

आपके एजेंट को AI एजेंट के विचार पर आपसे इंटरव्यू लेने और कुछ भी लॉन्च होने से पहले आपके जवाबों को सरल निर्माण योजना में बदलने देती है।

AI और एजेंटएजेंट

run-without-you

29k

आपके एजेंट को मैनेज्ड AI एजेंट शेड्यूल पर या किसी घटना पर चलाने में मदद करती है, लॉन्च से पहले cron समय की जांच के साथ।

प्रोडक्टिविटीऑटोमेशन

मिलती-जुलती skills