feat(git): add squash merge option for branching strategies
- Add "Squash merge" as recommended option at complete-milestone - Keep "Merge with history" (--no-ff) as alternative - Document merge options in planning-config reference Improves on #298 based on community feedback from @oojacoboo. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -165,6 +165,17 @@ if [ "$BRANCHING_STRATEGY" = "milestone" ]; then
|
||||
fi
|
||||
```
|
||||
|
||||
**Merge options at complete-milestone:**
|
||||
|
||||
| Option | Git command | Result |
|
||||
|--------|-------------|--------|
|
||||
| Squash merge (recommended) | `git merge --squash` | Single clean commit per branch |
|
||||
| Merge with history | `git merge --no-ff` | Preserves all individual commits |
|
||||
| Delete without merging | `git branch -D` | Discard branch work |
|
||||
| Keep branches | (none) | Manual handling later |
|
||||
|
||||
Squash merge is recommended — keeps main branch history clean while preserving the full development history in the branch (until deleted).
|
||||
|
||||
**Use cases:**
|
||||
|
||||
| Strategy | Best for |
|
||||
|
||||
@@ -643,7 +643,8 @@ AskUserQuestion([
|
||||
header: "Branches",
|
||||
multiSelect: false,
|
||||
options: [
|
||||
{ label: "Merge to main", description: "Merge all branches to main sequentially" },
|
||||
{ label: "Squash merge (Recommended)", description: "Squash all commits into one clean commit on main" },
|
||||
{ label: "Merge with history", description: "Preserve all individual commits (--no-ff)" },
|
||||
{ label: "Delete without merging", description: "Branches already merged or not needed" },
|
||||
{ label: "Keep branches", description: "Leave branches for manual handling later" }
|
||||
]
|
||||
@@ -651,7 +652,34 @@ AskUserQuestion([
|
||||
])
|
||||
```
|
||||
|
||||
**If "Merge to main":**
|
||||
**If "Squash merge":**
|
||||
|
||||
```bash
|
||||
CURRENT_BRANCH=$(git branch --show-current)
|
||||
git checkout main
|
||||
|
||||
# For phase strategy - squash merge each phase branch
|
||||
if [ "$BRANCHING_STRATEGY" = "phase" ]; then
|
||||
for branch in $PHASE_BRANCHES; do
|
||||
echo "Squash merging $branch..."
|
||||
git merge --squash "$branch"
|
||||
git commit -m "feat: $branch for v[X.Y]"
|
||||
done
|
||||
fi
|
||||
|
||||
# For milestone strategy - squash merge milestone branch
|
||||
if [ "$BRANCHING_STRATEGY" = "milestone" ]; then
|
||||
echo "Squash merging $MILESTONE_BRANCH..."
|
||||
git merge --squash "$MILESTONE_BRANCH"
|
||||
git commit -m "feat: $MILESTONE_BRANCH for v[X.Y]"
|
||||
fi
|
||||
|
||||
git checkout "$CURRENT_BRANCH"
|
||||
```
|
||||
|
||||
Report: "Squash merged branches to main"
|
||||
|
||||
**If "Merge with history":**
|
||||
|
||||
```bash
|
||||
CURRENT_BRANCH=$(git branch --show-current)
|
||||
@@ -674,7 +702,7 @@ fi
|
||||
git checkout "$CURRENT_BRANCH"
|
||||
```
|
||||
|
||||
Report: "Merged branches to main"
|
||||
Report: "Merged branches to main with full history"
|
||||
|
||||
**If "Delete without merging":**
|
||||
|
||||
|
||||
Reference in New Issue
Block a user