From empire-git
Merges one git worktree branch into a target branch using git merge --no-ff. Use to fold sub-features, batch small fixes into one branch before PR, or combine worktrees locally.
npx claudepluginhub marcoskichel/empire --plugin empire-git<branch> --into <target> [--no-close] [--ff]This skill is limited to using the following tools:
Merge a worktree's branch into a target branch. This is always a real `git merge` — the target is a local branch where the worktree's commits get folded in.
Mandates invoking relevant skills via tools before any response in coding sessions. Covers access, priorities, and adaptations for Claude Code, Copilot CLI, Gemini CLI.
Share bugs, ideas, or general feedback.
Merge a worktree's branch into a target branch. This is always a real git merge — the target is a local branch where the worktree's commits get folded in.
User input: $ARGUMENTS
If currently inside a worktree (not the main working tree):
If $ARGUMENTS specifies a branch name or worktree path:
git worktree list --porcelain.If neither:
git worktree list and ask the user which one to merge.Record the worktree path and branch name for subsequent steps.
The target is where the source branch's commits will be merged into.
If --into <target> is in the arguments: use that branch.
If no target is specified: ask the user which branch to merge into. Common choices:
main — the default branchfeat/auth when merging feat/auth-nav)The target branch must be checked out somewhere — either in the main working tree or in another worktree. Find it:
git worktree list --porcelain
If the target branch isn't checked out anywhere, check it out in the main working tree first.
git -C "<source-worktree-path>" status --porcelain
If there are uncommitted changes, stop and tell the user:
This worktree has uncommitted changes. Please commit them first (e.g., run
/commit), then re-run/empire-git:worktree-merge.
git -C "<source-worktree-path>" log --oneline <target>..<source-branch>
If there are no commits ahead of the target, stop:
Branch
<source>has no new commits relative to<target>. Nothing to merge.
Default merge mode: --no-ff (preserves branch history as a merge commit, easier to read and revert).
If --ff was in $ARGUMENTS, omit --no-ff and let git fast-forward when possible. Use this for rebase-only or linear-history teams.
# Default
git -C "<target-worktree-path>" merge "<source-branch>" --no-ff
# With --ff
git -C "<target-worktree-path>" merge "<source-branch>"
If your team forbids merge commits entirely, this skill is the wrong tool — use git rebase directly in the source worktree, then worktree-close --push.
If merge conflicts occur:
git -C "<target-worktree-path>" diff --name-only --diff-filter=U
/empire-git:worktree-close on the source worktree when ready.On success, print:
Merged '<source-branch>' into '<target-branch>'.
If --no-close was in the arguments, skip this step and just print the result. The user may want to keep the source worktree around for further work.
Otherwise, present the same cleanup options as /empire-git:worktree-close:
After a successful merge, default to option 2 — the branch's commits are now in the target, so the source branch has served its purpose.
Execute the chosen option:
# Option 1 or 2: remove the worktree
git worktree remove "<source-worktree-path>"
# Option 2 only: also delete the branch (safe delete)
git branch -d "<source-branch>"
Then prune:
git worktree prune
Print a summary of what was done.
Batching small fixes: Several small worktree branches (typo, dep bump, color tweak) merged locally into one branch before opening a single PR:
/empire-git:worktree-merge fix/typo --into feat/cleanup
/empire-git:worktree-merge fix/deps --into feat/cleanup
/empire-git:worktree-merge fix/color --into feat/cleanup
# Then open one PR from feat/cleanup
Branch decomposition: Sub-branches merged back into a parent feature branch:
/empire-git:worktree-merge feat/auth-nav --into feat/auth
/empire-git:worktree-merge feat/auth-table --into feat/auth
# Then open one PR from feat/auth
This skill does one thing: git merge. For pushing to remote, use /empire-git:worktree-close --push. For opening PRs, use the user's own PR workflow. Keeping these concerns separate avoids conflicts with existing conventions.
Merge conflicts need human judgment. When conflicts occur, clearly list the affected files and let the user decide. Attempting to auto-resolve risks silently introducing bugs.
Use git branch -d (safe delete), not -D. If the safe delete fails after a merge, something unexpected happened — surface it rather than force through.