Branching and merging

Branching and Merging

This guide will detail how to create feature branches of our project repositories to work on, and how to then submit them for review before merging back into the central project.

Bzr and Launchpad

Here are the steps to work on a new feature of an existing project in Launchpad:

  • Branch the project locally
  • Do some work
  • Push to a new branch under your own username
  • When the work is finished, submit a Merge Proposal (MP)
  • Once your MP has been reviewed, merge your user branch into the central repository

Working on a user branch

For example, if we assume:

  • Our Launchpad username is geeky-dev
  • We’re working on a project called example-project, hosted at
  • We’re developing a new login feature
# Pull the latest version to a new "example-project-login" directory
bzr branch lp:example-project example-project-login
# Enter the new project directory
cd example-project-login
# ... do some initial work for the feature ...
# Commit your new work
bzr commit -m 'Create login form'
# Create your user branch of example-project called "login"
bzr push lp:~geeky-dev/example-project/login
# ... do some more work ...
bzr commit -m 'Implement login view'
# Push to your user branch again, which is now remembered
bzr push

Creating a Merge Proposal (MP)

Now if your work is finished and you’re ready to have it reviewed, go and submit a Merge Proposal (MP) on Launchpad:

  • To browse to the “Propose branch for merging” form for your branch on Launchpad, either:
    • Select the “Code” tab on the project’s Launchpad page (e.g:, select the relevant branch, and select “Propose for merging”
    • ‘’‘OR’’’ form a URL from, your user branch (e.g.: ~geeky-dev/example-project) and /+register-merge (e.g.:
  • The main project should be selected as the project to merge into (e.g.: lp:example-project)
  • Give your MP a description and add a reviewer, who will be emailed
  • Consider pinging the reviewer directly on IRC to ask them to review your MP - MPs should be top priority
  • When the reviewer has reviewed and approved your changes, they should set the state of the MP to “Approved”, and you should get an email

Merging your branch into the main project

Once your MP has been approved, you can merge the project as follows:

bzr push lp:example-project  # Push your branch up to the main project branch

If you get an error saying something like “These branches have diverged”, then you need to do a merge first:

# Make sure your branch has the latest changes from lp:example-project
bzr merge lp:example-project
# If there are any changes to merge, create a merge commit
bzr commit -m 'Merging trunk into login branch'
# Now try to push up your branch again
bzr push lp:example-project

This should automatically set the status of your merge proposal to “Merged”.

Git and Github

** Coming soon **

1 Like