Tower Help & Support

Committing Changes to Stacked Branches

In the Graphite workflow, committing changes to stacked branches requires special consideration to maintain the proper relationships between branches in your stack. Tower provides several options for committing changes to stacked branches.

Regular Commits

You can create regular commits on a stacked branch just as you would on any other branch:

  1. Make your changes to files in your working copy
  2. Stage the changes you want to include in your commit
  3. Enter a commit message
  4. Click the Commit button

When you create a regular commit on a stacked branch, the following actions will be performed:

  • Add the commit to the current branch
  • Maintain the branch's position in the stack
  • Automatically restack child branches if possible

This is equivalent to using the gt modify --commit command in the Graphite CLI.

Modifying Commits (Amending)

In Graphite terminology, "modifying" a commit means amending the last commit on a branch. This is particularly useful when you need to make small adjustments to your most recent changes:

  1. Make additional changes to files in your working copy
  2. Stage the changes you want to include
  3. Check the Amend checkbox in the commit view, which will change the Commit button to Modify
  4. Click the Modify button

When you click the Modify button, the following actions will be performed:

  • Amend the last commit on the current branch
  • Automatically restack child branches if possible

This is equivalent to using the gt modify command in the Graphite CLI.

Quick Tip
Hold down the Option key to quickly switch to "Modify" mode without checking the Amend checkbox. This temporarily changes the Commit button to Modify while the key is pressed.

Creating a New Stacked Branch with a Commit

If you want to create a new stacked branch and commit changes to it in one step:

  1. Make your changes to files in your working copy
  2. Stage the changes you want to include
  3. In the commit view, click the Create button

When you click the Create button, the following actions will be performed:

  • Create a new stacked branch based on the current branch (the branch name will be auto-generated from your commit message)
  • Commit all staged changes to this new branch
  • Automatically set up the proper parent-child relationship in the stack

This is equivalent to using the gt create command in the Graphite CLI.

Automatic Restacking

One of the powerful features of Graphite is automatic restacking of child branches. When you modify a commit or create a new commit on a branch that has child branches, Graphite will attempt to automatically restack those child branches to maintain the proper relationships.

This means that changes to a parent branch will be propagated to all child branches, ensuring that each branch in the stack builds upon the latest changes in its parent.

Handling Conflicts During Restacking

If there are conflicts during the automatic restacking process, Tower will notify you and provide options for resolving them:

  1. The restacking operation will pause
  2. Tower will show the conflicting files
  3. You can resolve the conflicts using Tower's conflict resolution tools
  4. After resolving conflicts, you can continue the restacking process

Best Practices for Committing in Stacked Branches

When working with stacked branches in Graphite, consider these best practices:

  • Keep commits focused on a single logical change
  • Use descriptive commit messages that clearly explain the purpose of the change
  • Prefer modifying (amending) the last commit rather than creating multiple small commits for the same logical change
  • Regularly restack your branches to ensure they stay up-to-date with changes in their parent branches