Branch Dependencies
With Branch Dependencies, you can create relationships between branches by setting a parent branch for a branch. This is usually the branch that your current branch was created from.
In a simple example, creating a feature branch “my-feature” from branch “main” will set “main” as the parent of “my-feature”. In this simple parent-child relationship the parent branch “main“ can also be called the base branch of “my-feature”.
Knowing the parent of a branch allows for some advanced features in Tower, for example:
- When comparing a branch (via the “Compare” button in its history), Tower can automatically select its parent branch to see immediately which commits have been introduced on this particular branch.
- When creating a Pull Request for a branch, Tower already knows its base branch and can propose it by default.
- Tower knows when a feature branch is behind its base branch and can offer the user to merge those changes into the feature branch to stay up-to-date with changes introduced by the parent. This reduces the likelihood and complexity of merge conflicts when later merging into the parent.
- Tower can automatically determine wether or not a branch has been fully merged into its parent (if a regular merge was used).
Stacked Branches
You can also create further child branches of a branch to create multiple branches that depend on each other. This is called “stacking” of branches.
You can read more about this feature in our guide “Working with Stacked Branches”.
Setting and Unsetting the parent branch
When creating a new branch, the starting point of the branch will be set as parent branch – if the starting point is another branch.
You set or unset the parent of a branch using the context menu on branch in the sidebar. By default, only base branches and branches that are direct ancestors (meaning the current tip of the branch is fully included in the selected branch) of the branch are offered as available parent branches, but you can select any branch as parent branch through a dialog.