Tower Help & Support

Merging & Rebasing

Integrating changes from one branch into another can be done via merge or rebase.

Before You Integrate...

Before starting a merge or rebase, you should check a couple of things:

  1. Your working copy should be clean. In case any local changes are present, use Git's Stash to temporarily save them away.
  2. Check out the branch that should receive the changes. The other branch will not be modified by the operation in any way.

Merging Branches

The most common method to integrate one branch into another is to perform a „merge“. To merge changes from another branch into your current HEAD, you can do the following:

  • click the Merge button in the toolbar

Rebasing Branches

When doing a rebase, Git takes all the commits from one branch and reapplies them (like patches) on the other branch one after the other. Thereby, history is rewritten: It will appear as if the commits had been made consecutively on the same branch, not on a different branch. No merge commit will be created, but commits will have new SHA1-IDs.

As a golden rule you should never rebase commits that have already been published on a remote repository (pushed).

To rebase your HEAD branch onto another branch, you can do the following:

  • click the Rebase button in the toolbar

Using the --onto Option for Rebase

The "Rebase" command is well known in Git, but not its --onto option, which can be immensely helpful. In short, rebase --onto allows you to "switch the base" for a series of commits.

A common, practical use case for this is when you want to switch the base of a feature branch to a different branch:

A normal rebase wouldn't work for this scenario. rebase --onto allows you to be much more precise.

For maximum flexibility, Tower also offers to use the rebase onto option with specific commits. Simply select a range of commits, right-click and choose the “Rebase X revisions onto…” action. You will be prompted with a dialog where you can select the revision to rebase onto.



Tip: Learn more about merge & rebase in our learn section.