@@ -4,14 +4,14 @@ Migrate changes from a worktree to a new branch cut from main (or a specified ba
44
55## Arguments
66
7- $ARGUMENTS = ` [branch-name ] [base-branch =main] `
7+ $ARGUMENTS = ` [branch_name ] [base_branch =main] `
88
9- - ** branch-name ** (optional): Name of the branch to create (e.g., ` feat/add-buy-agent ` )
10- - ** base-branch ** (optional): Base branch to cut from (default: ` main ` )
9+ - ** branch_name ** (optional): Name of the branch to create (e.g., ` feat/add-buy-agent ` )
10+ - ** base_branch ** (optional): Base branch to cut from (default: ` main ` )
1111
12- ### Auto-generated Branch Name (when branch-name is omitted)
12+ ### Auto-generated Branch Name (when branch_name is omitted)
1313
14- When branch-name is omitted, the branch name is automatically determined from the ** change analysis in Step 2** .
14+ When branch_name is omitted, the branch name is automatically determined from the ** change analysis in Step 2** .
1515
1616#### Auto-naming Rules
1717
@@ -52,38 +52,38 @@ git branch --show-current
5252# Full picture of changes (staged + unstaged + untracked)
5353git status --porcelain=v1
5454
55- # Committed changes ahead of origin/base-branch
56- git log origin/${base-branch } ..HEAD --oneline 2> /dev/null || echo " No commits ahead"
55+ # Committed changes ahead of origin/base_branch
56+ git log origin/${base_branch } ..HEAD --oneline 2> /dev/null || echo " No commits ahead"
5757
58- # Diff stat against origin/base-branch
59- git diff origin/${base-branch } --stat 2> /dev/null
58+ # Diff stat against origin/base_branch
59+ git diff origin/${base_branch } --stat 2> /dev/null
6060
6161# Fetch latest from remote
62- git fetch origin ${base-branch }
62+ git fetch origin ${base_branch }
6363```
6464
6565### 2. Analyze Changes
6666
67- 1 . Analyze ** all changes** by combining ` git diff origin/${base-branch } ` (committed + unstaged) with untracked files
67+ 1 . Analyze ** all changes** by combining ` git diff origin/${base_branch } ` (committed + unstaged) with untracked files
68682 . Read the content of each changed file and determine:
6969 - Functional grouping (which responsibility/layer each change belongs to)
7070 - Intent of each group (feat / fix / refactor / chore / docs / test / style / perf)
7171 - Appropriate scope (e.g., db, api, web, infra, auth, etc.)
72723 . Plan the commit strategy (following the format described below)
73- 4 . ** If branch-name was omitted** : Determine the branch name from the analysis above using the auto-naming rules
73+ 4 . ** If branch_name was omitted** : Determine the branch name from the analysis above using the auto-naming rules
7474 - Generate ` ${type}/${slug} ` from the most dominant type and scope across all changes
7575 - If an active spec exists under ` .kiro/specs/ ` , reflect its feature name in the slug
7676
7777### 3. Create Branch and Migrate Changes
7878
79- ** Case A: Uncommitted changes only (HEAD is the same as origin/${base-branch }, or no commits ahead)**
79+ ** Case A: Uncommitted changes only (HEAD is the same as origin/${base_branch }, or no commits ahead)**
8080
8181``` bash
8282# Stash all changes
83- git stash push -u -m " worktree-pr: temp stash for ${branch-name } "
83+ git stash push -u -m " worktree-pr: temp stash for ${branch_name } "
8484
85- # Create new branch from origin/${base-branch }
86- git checkout -b ${branch-name } origin/${base-branch }
85+ # Create new branch from origin/${base_branch }
86+ git checkout -b ${branch_name } origin/${base_branch }
8787
8888# Apply stashed changes
8989git stash pop
@@ -93,19 +93,19 @@ git stash pop
9393
9494``` bash
9595# Record the range of committed changes
96- FIRST_COMMIT=$( git log origin/${base-branch } ..HEAD --reverse --format=' %H' | head -1)
96+ FIRST_COMMIT=$( git log origin/${base_branch } ..HEAD --reverse --format=' %H' | head -1)
9797LAST_COMMIT=$( git rev-parse HEAD)
9898
9999# Stash uncommitted changes if any
100- git stash push -u -m " worktree-pr: temp stash for ${branch-name } " 2> /dev/null
100+ git stash push -u -m " worktree-pr: temp stash for ${branch_name } " 2> /dev/null
101101
102- # Create new branch from origin/${base-branch }
103- git checkout -b ${branch-name } origin/${base-branch }
102+ # Create new branch from origin/${base_branch }
103+ git checkout -b ${branch_name } origin/${base_branch }
104104
105105# Cherry-pick committed changes
106106git cherry-pick ${FIRST_COMMIT} ^..${LAST_COMMIT}
107107# If cherry-pick conflicts: fall back to soft reset for manual commit
108- # git reset --soft origin/${base-branch }
108+ # git reset --soft origin/${base_branch }
109109
110110# Apply stash if present
111111git stash pop 2> /dev/null
@@ -114,14 +114,14 @@ git stash pop 2>/dev/null
114114** Case C: Patch-based migration (fallback when Case B conflicts)**
115115
116116``` bash
117- # Create patch of all diffs against origin/${base-branch }
118- git diff origin/${base-branch } > /tmp/worktree-pr.patch
117+ # Create patch of all diffs against origin/${base_branch }
118+ git diff origin/${base_branch } > /tmp/worktree-pr.patch
119119
120120# Archive untracked files
121- git ls-files --others --exclude-standard -z | xargs -0 tar czf /tmp/worktree-pr-untracked.tar.gz 2> /dev/null
121+ git ls-files --others --exclude-standard -z | xargs -0 --no-run-if-empty tar czf /tmp/worktree-pr-untracked.tar.gz 2> /dev/null
122122
123123# Create new branch
124- git checkout -b ${branch-name } origin/${base-branch }
124+ git checkout -b ${branch_name } origin/${base_branch }
125125
126126# Apply patch
127127git apply /tmp/worktree-pr.patch
@@ -138,7 +138,7 @@ Based on the analysis from Step 2, commit changes in logical groups. **Follow `.
138138### 5. Push
139139
140140``` bash
141- git push -u origin ${branch-name }
141+ git push -u origin ${branch_name }
142142```
143143
144144### 6. Create PR
@@ -181,7 +181,7 @@ Create a pull request using `gh pr create`.
181181
182182``` bash
183183gh pr create \
184- --base ${base-branch } \
184+ --base ${base_branch } \
185185 --title " ${pr_title} " \
186186 --body " $( cat << 'EOF '
187187${pr_body}
@@ -208,6 +208,6 @@ Report the PR URL to the user as the final output.
208208- Follow ` .gitignore ` strictly. Additionally, never stage ` .env ` , ` .cursor/** ` (except commands)
209209- Never commit files containing credentials or secrets
210210- If a conflict occurs, report the situation to the user and ask for instructions
211- - Default base-branch to ` main ` when omitted
212- - Auto-generate branch-name from change analysis when omitted (see auto-naming rules)
213- - If the branch-name (specified or auto-generated) already exists, report an error and suggest an alternative name
211+ - Default base_branch to ` main ` when omitted
212+ - Auto-generate branch_name from change analysis when omitted (see auto-naming rules)
213+ - If the branch_name (specified or auto-generated) already exists, report an error and suggest an alternative name
0 commit comments