worktree-pr-merge

Merge PRs sequentially across Git worktrees with rebase timing and dotnet restore.

9|1|Updated Jul 21, 2025
One-click install
npx skills add https://github.com/usepowershell/PoshMcp --skill worktree-pr-merge
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: worktree-pr-merge
Source: https://github.com/usepowershell/PoshMcp/tree/main/.squad/skills/worktree-pr-merge
Command: npx skills add https://github.com/usepowershell/PoshMcp --skill worktree-pr-merge

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Git worktrees enable parallel PR development by creating isolated branch checkouts tied to the main worktree. Merging PRs sequentially to main requires coordinating state across worktrees to avoid build failures, false exit codes, and branch push issues. This skill codifies the recurring patterns that ensure deterministic merges and reliable automation.

Core Features & Use Cases

  • Rebase timing: Ensure subsequent worktrees rebase after each preceding PR lands to main.
  • Dotnet restore on cold worktrees: Run dotnet restore before dotnet test --no-restore when a worktree has never been built to avoid NETSDK1004.
  • Correct interpretation of gh pr merge exit codes: The local branch-delete step may fail with non-zero exit while the merge succeeded on GitHub; do not treat this as a failure.
  • Force-push with explicit remote: When a worktree branch has no upstream, use explicit remote reference: git push --force-with-lease origin <branch>.
  • Sequential merge discipline: When multiple PRs touch the same files, merge them to main sequentially to avoid conflicts.

Quick Start

Start by updating the main worktree, then merge subsequent PRs sequentially and rebase after each merge.

Frequently Asked Questions about worktree-pr-merge

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

FAQPage Schema
How do I merge multiple PRs sequentially using Git worktrees without causing build failures?

To merge multiple PRs sequentially using Git worktrees, update the main worktree first, then merge subsequent PRs one by one and rebase each worktree after the preceding PR lands to maintain consistent state and avoid build failures.

Why does my PR merge fail when deleting a local branch after using the gh CLI?

Your PR merge may appear to fail because the local branch-delete step returns a non-zero exit code, but the actual GitHub merge succeeded. When merging PRs across worktrees, you should not treat this specific local deletion exit code as a failure.

How do I fix NETSDK1004 errors when running dotnet test on a cold Git worktree?

To fix NETSDK1004 errors on a cold Git worktree, run `dotnet restore` before executing `dotnet test --no-restore` to ensure dependencies are downloaded for branches that have never been built locally.

How do I force-push a branch in a Git worktree that has no upstream set?

To force-push a branch in a Git worktree that has no upstream set, use the explicit remote reference command: `git push --force-with-lease origin <branch>` to ensure correct branch push behavior and avoid merge errors.

When should I rebase worktrees during a multi-branch PR merge workflow?

You should rebase worktrees after each preceding PR merges to main. This sequential merge discipline ensures subsequent worktrees remain consistent with main and prevents file conflicts when multiple PRs touch the same files.

What is the best way to coordinate parallel PR development across isolated Git worktrees?

The best way to coordinate parallel PR development is to use sequential merge discipline across worktrees, ensuring deterministic execution, correct handling of merge exit codes, and explicit upstream pushes to avoid false build failures and merge errors.