Skip to main content
gx nuke deletes branches thoroughly: local branch, remote tracking ref, and remote branch in one operation. It supports glob patterns for batch deletion and has safety guards to prevent accidents.

Usage

gx nuke <branch-or-pattern> [flags]
gx nuke --orphans [flags]

Arguments

ArgumentDescription
branch-or-patternBranch name or glob pattern (e.g., feature/*)

Flags

FlagShortDescription
--localOnly delete the local branch (skip remote)
--dry-runShow what would be deleted without making changes
--yes-ySkip confirmation prompts
--orphansDelete all orphaned branches from the stack

Examples

$ gx nuke feature/old-auth

  feature/old-auth is NOT merged into main.

Proceed with deletion? [y/N] y
OK Deleted local branch feature/old-auth
OK Deleted remote tracking ref origin/feature/old-auth
OK Deleted remote branch origin/feature/old-auth

Safety Guards

gx nuke includes several safety measures:
GuardBehavior
Current branchCannot nuke the branch you are on. gx prints ERROR Cannot nuke '<branch>': it's the current branch. Switch first.
HEAD branchCannot nuke main/master. gx prints ERROR Cannot nuke '<branch>': it's the HEAD branch. Blocked for safety.
Unmerged warningBranches not merged into the HEAD branch are flagged with a prominent warning
Stack childrenIf the branch has dependent branches in the stack, gx warns they will become orphaned
ConfirmationAlways asks for confirmation (unless --yes), and always asks when unmerged branches are involved even with --yes
Deleting a branch that has children in the stack will orphan those children. They will appear in gx graph with the ! orphaned indicator. Use gx nuke --orphans later to clean them up, or use gx retarget to reparent them first.

Merged vs Unmerged

  • Merged branches are deleted with git branch -d (safe delete)
  • Unmerged branches are deleted with git branch -D (force delete)
The merge status is checked against the HEAD branch using git branch --merged.

Orphan Mode

gx nuke --orphans finds all branches in the stack config whose parent no longer exists and offers to delete them in batch. This is useful after merging and deleting parent branches.
  • Glob patterns are resolved against all local branches
  • Remote deletion uses git push origin --delete <branch>
  • Remote tracking refs are cleaned up with git branch -dr origin/<branch>
  • After deletion, the branch is removed from the stack config
  • When a branch is removed from the config, its children are also removed (they become orphaned)