Documentation
Branch Lifecycle
Delete, move, fold, and rename branches while keeping the stack valid.
gs delete
Delete a branch and its metadata from the stack. Children are reparented to the deleted branch's parent and restacked.
# Interactive selection of branch to delete
gs delete
# Delete specific branch
gs delete feat-old
# Delete without confirmation
gs delete -f feat-old
# Short aliases
gs d feat-old
gs rm feat-oldFlags: -f, --force — delete without confirmation
Aliases: d, remove, rm
When to use:
- Removing completed or abandoned feature branches
- Cleaning up your stack after merging to trunk
- Restructuring your stack by removing intermediate branches
gs move
Rebase the current branch onto a different parent. Descendants are automatically restacked.
# Interactive selection of target branch
gs move
# Move current branch onto feat-base
gs move feat-base
# Using --onto flag
gs move -o feat-base
# Short alias
gs mv feat-baseFlags: -o, --onto — specify target branch
Alias: mv
What it does:
- Changes the parent of the current branch
- Rebases the current branch onto the new parent
- Automatically restacks all children branches
- Prevents circular dependencies (won't move onto descendants)
When to use:
- Reorganizing your stack structure
- Moving a feature branch to depend on a different parent
- Extracting a branch from one stack to another
gs fold
Fold the current branch's changes into its parent. Squash-merges the commits, reparents children, and deletes the branch.
# Fold current branch into parent
gs fold
# Keep current branch instead of deleting it
gs fold --keep
# Skip confirmation prompt
gs fold --force
gs fold -fFlags:
| Flag | Long | Description |
|---|---|---|
-k | --keep | Keep the branch instead of deleting it |
-f | --force | Skip confirmation prompt |
When to use:
- When a branch should have been part of its parent
- Simplifying a stack by collapsing intermediate branches
- Combining multiple small changes into a single branch
gs rename
Rename the current branch. All metadata references are updated automatically.
gs rename feat-auth-v2When to use:
- Before submitting a PR with a better name
- Fixing naming conventions