Managing Stacked Branches
Tower provides a comprehensive set of tools for managing your stacked branches in Graphite. These tools help you maintain the proper relationships between branches and perform various management operations.
Restacking Branches
Restacking is a core operation in the Graphite workflow. It ensures that child branches are updated with changes from their parent branches.
To restack a branch, select it and access the Restack action through the gt restack
command in the Graphite CLI.
Branch Status Indicator
Tower will indicate branches that need to be restacked in the sidebar with a special stack icon that has an exclamation mark. This visual indicator helps you quickly identify branches that require attention due to changes in their parent branches.
When restacking a branch, the following actions will be performed:
- Rebase the selected branch onto its parent
- Propagate changes from the parent branch to the selected branch
- Optionally restack all child branches as well
When restacking, Tower will restack from the trunk branch up to your selected branch by default. For a more comprehensive update, you can choose the
option, which will also restack all child branches below your selected branch.Restacking is particularly important after:
- Making changes to a parent branch
- Pulling changes from a remote repository
- Resolving conflicts in a parent branch
Deleting Stacked Branches
To delete a stacked branch, select it and access the Delete action through the branch's context menu. This action corresponds to the gt delete
command in the Graphite CLI.
When deleting a branch, the following actions will be performed:
- Delete the selected branch
- Update the relationships between remaining branches in the stack
Important
Always use the Graphite delete action rather than standard Git branch deletion. This ensures that the stack relationships are properly maintained and child branches are correctly restacked.
Renaming Branches in a Stack
To rename a stacked branch, select it and access the Rename action through the branch's context menu, then enter a new name. This action corresponds to the gt rename
command in the Graphite CLI.
When renaming a branch, the following actions will be performed:
- Rename the branch
- Maintain its position in the stack
Important
Always use the Graphite rename action rather than standard Git branch renaming. This ensures that the stack relationships are properly maintained and metadata is correctly updated.
Tracking and Untracking Branches with Graphite
To track a branch in the Graphite workflow, select it and access the Track action through the branch's context menu. When tracking a branch, you'll need to select a parent branch to establish the proper relationship in the stack. This action corresponds to the gt track
command in the Graphite CLI.
When tracking a branch, the following actions will be performed:
- Add the branch to the Graphite tracking system
- Establish the relationship with the selected parent branch
- Update the branch's metadata to include Graphite-specific information
You can also untrack a branch that's already being tracked by Graphite. To do this, select the branch and access the Untrack action through the branch's context menu. This action corresponds to the gt untrack
command in the Graphite CLI.
When untracking a branch, the following actions will be performed:
- Remove the branch from the Graphite tracking system
- The branch will remain in your repository but will no longer be managed as part of a stack
Squashing Commits in a Stacked Branch
Squashing combines multiple commits in a branch into a single, consolidated commit. This is particularly useful when you want to clean up your commit history before merging or when you have several small, incremental commits that make more sense as a single logical change.
To squash commits in a branch, select the branch containing the commits you want to squash in the sidebar and access the Squash action through the branch's context menu.
This action corresponds to the gt squash
command in the Graphite CLI.
When squashing a branch, the following actions will be performed:
- Combine all commits in the branch into a single commit
- Restack child branches to maintain the proper relationships