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 one of the following:

  1. click the Merge button in the toolbar
  2. drag the branch in the sidebar and drop it onto your current HEAD branch item

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 one of the following:

  1. click the Rebase button in the toolbar
  2. drag the branch in the sidebar and, while holding down the OPT key, drop it onto your current HEAD branch item



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