cub merge¶
Merge pull requests with CI verification.
Synopsis¶
Description¶
The cub merge command merges pull requests after verifying CI status. It supports different merge methods (squash, merge, rebase) and can optionally delete the source branch after merging.
The command:
- Verifies all CI checks have passed
- Merges the PR using the specified method
- Updates the branch binding status to
merged - Optionally deletes the source branch
Options¶
| Option | Description |
|---|---|
<target> | Epic ID, branch name, or PR number (required) |
-m, --method <method> | Merge method: squash, merge, or rebase (default: squash) |
--no-delete | Don't delete branch after merge |
-f, --force | Merge even if checks are failing |
-n, --dry-run | Show what would be done without making changes |
Subcommands¶
cub merge wait¶
Wait for CI checks to complete before proceeding.
| Option | Description |
|---|---|
<target> | Epic ID, branch name, or PR number (required) |
--timeout <seconds> | Timeout in seconds (default: 600) |
Examples¶
Merge an Epic¶
Merge by PR Number¶
Merge by Branch Name¶
Different Merge Methods¶
# Use merge commit instead of squash
cub merge cub-vd6 --method merge
# Use rebase
cub merge cub-vd6 --method rebase
Keep Branch After Merge¶
Force Merge¶
Dry Run¶
Wait for CI¶
# Wait for checks to pass, then merge
cub merge wait cub-vd6
cub merge cub-vd6
# With custom timeout (20 minutes)
cub merge wait cub-vd6 --timeout 1200
Merge Methods¶
| Method | Description |
|---|---|
squash | Combine all commits into one (default) |
merge | Create a merge commit |
rebase | Rebase commits onto base branch |
When to Use Each¶
Squash (default): - Clean history with one commit per feature - Simplifies reverting features - Good for most feature branches
Merge: - Preserves full commit history - Clear branch topology in history - Good for long-running branches
Rebase: - Linear history - Individual commits preserved - Good for small, incremental changes
CI Verification¶
By default, cub merge checks CI status before merging:
If checks are failing:
If checks are still running:
CI checks still running:
- deploy-preview: in_progress
Wait for checks to complete or use --force to merge anyway
Force Merge¶
Use --force to bypass CI verification:
Use this cautiously - only when you understand why checks are failing and have manually verified the code is safe to merge.
Workflow Examples¶
Standard Workflow¶
# Create and push PR
cub pr cub-vd6 --push
# Wait for CI
cub merge wait cub-vd6
# Merge when ready
cub merge cub-vd6
Automated Pipeline¶
# In a script or CI job
cub merge wait cub-vd6 --timeout 1800 # 30 min timeout
if [ $? -eq 0 ]; then
cub merge cub-vd6
else
echo "CI failed or timed out"
exit 1
fi
Keep Branch for Debugging¶
# Merge but keep the branch
cub merge cub-vd6 --no-delete
# Later, manually delete
git push origin --delete feature/cub-vd6
Quick Merge for Hotfixes¶
Output¶
Successful Merge¶
Or with --no-delete:
Dry Run¶
Exit Codes¶
| Code | Meaning |
|---|---|
| 0 | Merge successful |
| 1 | Error (CI failed, PR not found, etc.) |
| 130 | Interrupted (Ctrl+C during wait) |
Prerequisites¶
- GitHub CLI (
gh) must be installed and authenticated - PR must exist for the target
- You must have permission to merge
Troubleshooting¶
"CI checks failed"¶
Fix the failing checks or use --force:
# Check what's failing
cub pr status cub-vd6
# Fix issues, push, then merge
git push origin feature/cub-vd6
cub merge wait cub-vd6
cub merge cub-vd6
"No PR found"¶
Create a PR first:
"Cannot merge - conflicts"¶
Resolve conflicts locally:
git checkout feature/cub-vd6
git rebase main
# Resolve conflicts
git push --force-with-lease
cub merge cub-vd6
Timeout During Wait¶
Increase timeout or check CI status:
# Longer timeout
cub merge wait cub-vd6 --timeout 1800
# Check what's taking long
cub pr status cub-vd6
Related Commands¶
cub pr- Create pull requestscub branch- Create and bind branchescub branches- List branch bindings (includes merge status)cub worktree- Parallel work with worktrees