DubStack
Commands

dub rename

Rename a tracked branch and propagate the change through DubStack state, children's parent refs, and (when linked) the remote branch. The associated PR's head ref stays on the original branch name — GitHub doesn't allow editing a PR's head.

Usage

# Rename the current tracked branch
dub rename feat/new-name

# Rename a specific tracked branch by old/new
dub rename feat/old feat/new

# Rename without pushing the renamed branch (even if a PR exists)
dub rename feat/new-name --no-push

Behavior

dub rename:

  1. Validates that the new name is a legal git ref and doesn't collide with any tracked or untracked local branch.
  2. Runs git branch -m <old> <new>.
  3. Updates the branch's name in DubStack state.
  4. Re-parents every child of the old branch onto the new name.
  5. If the branch already has a PR linked, pushes the renamed branch to origin with --force-with-lease. Use --no-push to skip this step.
  6. Records a one-level undo entry. dub undo reverses the rename.

The old remote branch (when one existed) is not deleted automatically. The command surfaces a hint with the exact git push origin --delete <old> you'd run to clean it up. Existing PRs remain linked to their original head ref — relink or close them manually as needed.

Flags

FlagDescription
--no-pushSkip pushing the renamed branch even when a PR is linked

Errors

ConditionBehavior
New name collides with another tracked branchDubError with recovery hint to dub untrack the collider
New name collides with an untracked local branchDubError with recovery hint to dub delete or pick a different name
Source branch is not trackedDubError pointing at dub track
Source branch is the stack rootDubError — root branches cannot be renamed via dub rename
Invalid new branch nameDubError explaining git ref naming rules

Undo

dub rename feat/old feat/new
dub undo   # → renames feat/new back to feat/old and restores state

Undo restores the local branch name, the state file, and child parent links. It does not revert any push that already happened — the renamed branch remains on the remote. Re-push (dub submit) or delete the renamed remote branch manually if you need to fully roll back.

On this page