merge
Merge the current branch’s pull request via the GitHub API. Automatically handles rebasing descendants and updating PR bases.
Usage
rung mergerung merge --method mergerung merge --method rebaserung merge --no-deleteAliases
rung m— shorthand forrung merge
Options
| Option | Description |
|---|---|
-m, --method <method> | Merge method: squash (default), merge, or rebase |
--no-delete | Don’t delete the remote branch after merge |
Merge Methods
| Method | Description |
|---|---|
squash | Combines all commits into one (default) |
merge | Creates a merge commit |
rebase | Rebases commits onto the base branch |
What Merge Does
When you run rung merge:
- Merge PR — Merges the PR via GitHub API using the specified method
- Rebase descendants — Rebases all child branches onto the new base
- Update PR bases — Updates child PRs to point to the new base branch
- Remove from stack — Removes the merged branch from the stack
- Delete branches — Deletes local and remote branches (unless
--no-delete) - Pull changes — Pulls latest changes to keep local up to date
Example
# On feat-add-user-model with approved PR #41$ rung merge
✓ Merged PR #41 (squash)✓ Rebased feat-add-user-api onto main✓ Updated PR #42 base to main✓ Deleted branch feat-add-user-model✓ Pulled latest mainBefore
Stack ────────────────────────────────────────────────── ● ▶ feat-add-user-model #41 ← main ● feat-add-user-api #42 ← feat-add-user-model ● feat-add-user-tests #43 ← feat-add-user-api ──────────────────────────────────────────────────After
Stack ────────────────────────────────────────────────── ● ▶ feat-add-user-api #42 ← main ● feat-add-user-tests #43 ← feat-add-user-api ──────────────────────────────────────────────────Merge Order
Always merge from the bottom of the stack up (closest to main first). This ensures:
- Each PR has the correct context
- Reviewers see the full picture
- CI runs against the correct base
Using Different Methods
Squash Merge (Default)
rung merge# orrung merge --method squashCombines all commits into a single commit on the base branch. Good for clean history.
Regular Merge
rung merge --method mergeCreates a merge commit preserving all individual commits. Good for preserving detailed history.
Rebase Merge
rung merge --method rebaseReplays commits onto the base branch without a merge commit. Creates linear history.
Keep Remote Branch
If you want to keep the remote branch after merging:
rung merge --no-deleteUseful for:
- Preserving branch for reference
- Required by some CI/CD pipelines
- When you need to re-reference the branch later
JSON Output
$ rung merge --json{ "merged": { "branch": "feat-add-user-model", "pr": 41, "method": "squash" }, "rebased": [ { "branch": "feat-add-user-api", "new_base": "main", "commits": 2 } ], "updated_prs": [42], "deleted": ["feat-add-user-model"]}Requirements
- The PR must be approved and all checks passing
- You must have write access to the repository
- GitHub authentication must be configured
Notes
- The merge uses GitHub’s API, so it respects branch protection rules
- If descendant rebasing causes conflicts, you’ll need to resolve them
- After merging, your checkout moves to the first child branch (or main if no children)