Documentation
Restacking
Keep branches in sync when parents change.
Why restacking matters
In a stack, each branch is based on its parent. When you modify a parent branch (amend a commit, add new commits, or pull upstream changes), its children become out of sync — they're based on an old version of the parent. Restacking rebases each branch onto the current tip of its parent, restoring consistency.
gs stack restack
Ensure each branch in the current stack is based on its parent, rebasing if necessary.
# Restack current branch and all its children
gs stack restack
# Short aliases
gs stack r
gs stack fix
gs stack fWhat it does:
- Checks if the current branch needs rebasing onto its parent
- Performs the rebase if the parent has moved forward
- Recursively restacks all children branches
- Handles conflicts interactively (prompts you to resolve and continue)
When to use:
- After making changes to a parent branch
- When trunk has moved forward and you want to update your stack
- To fix "out of sync" branches in your stack
Aliases: r, fix, f
gs sync
Fetch remote changes, clean up stale branches, delete merged branches, and restack.
# Interactive cleanup
gs sync
# Force cleanup without prompts
gs sync -fWhat it does:
- Removes metadata for branches that no longer exist in git
- Validates trunk branch has no parent
- Detects cycles in branch relationships
- Ensures stack structure is valid