Skip to main content

gitq remove

Removes a branch from a tracked stack. A merged branch can go even when it has children; any other branch must be a leaf.

Usage​

bash
gitq remove <branch> [--stack <name>]

Flags​

flagmeaning
--stack <name>Which tracked stack to remove from. Optional when the repo has exactly one; required otherwise. See Global flags.

Behavior​

Pure bookkeeping: removes one node from the resolved stack (StackManager.removeNode, src/core/stack-manager.ts). The git branch and its commits are untouched.

  • Refuses with usage help if <branch> is missing.
  • Refuses if the stack can't be resolved: see the --stack rule at Global flags.
  • Guarded by the stack lease (requireStackFree, src/cli/slots.ts:19-27): refuses if the stack has a running or parked cascade.
  • Refuses if <branch> is not a node in the stack: gitq: Branch "<branch>" not found in stack "<id>" (src/core/stack-manager.ts:112-115).
  • A merged branch hands its children to its nearest unmerged ancestor, or to the stack root when every ancestor is merged. Only the tree changes: the children's commits stay where they are, and a child with no recorded fork point gets the merged branch's last known head as one, so the next gitq sync replays only their own commits onto the new parent.
  • Refuses any other branch that still has children. The error names the branch and how many child branches it has, then tells you to remove or re-parent them first. The wording here is a paraphrase; the literal source string uses an em dash this page does not reproduce. Re-parent the children onto a different branch, or remove them first, then retry.
  • Prints removed <branch> on success. Under --json, emits { stack: updatedStack }. See JSON output.

Exit codes​

  • 0: the branch was removed.
  • 1: any refusal above.

See Exit codes for the general contract.

See also​