Just as it's easy to create your own Bazaar branch of code that's registered in Launchpad, you can also host your code on Launchpad. It's free and means that your code is:
- available for anyone else to download and work with
- publicly associated with the project it relates to
- ready to take part in public merge requests and code review.
The easiest way to get your code on Launchpad is to push your branch using Bazaar. Alternatively, Launchpad can mirror a Bazaar branch that's hosted elsewhere on the internet or convert existing Subversion and CVS repositories into Bazaar branches.
Pushing your Bazaar branch to Launchpad
Registering your branch in Launchpad
First up, you need to tell Launchpad about your branch. Visit your branch registration page and follow the on-screen instructions.
Note: if you haven't already, you should read our guide to creating your own branch.
You should leave most of the options on the branch registration page at their default setting, other than:
Project: choose whichever project your code is a branch of
Branch type: choose Hosted as you want to host your branch on Launchpad.
Once you've clicked the Register branch button, you're ready to push your code up to Launchpad.
Making the first push
Before you do anything else, you need to tell Launchpad who you are and then ask Bazaar to log into Launchpad using your account. If you haven't already, register your SSH key with Launchpad. Next, open up a terminal and enter:
$ bzr launchpad-login your-id
Replace your-id with your Launchpad id - e.g. matthew.revell rather than your email address.
On your new branch's overview page, you'll see the Bazaar command you need to issue in order to push your branch up to Launchpad.
Open up a terminal and enter:
$ bzr launchpad-login your-username
Note: The username you need to use in place of your-username is your Launchpad username. This isn't the email address you use to log into Launchpad but is instead the final portion of the URL of your profile page.
If your login is successful, Bazaar will give you no message.
Now, copy the Update this branch: command from your branch's overview page and paste it in your terminal. Before hit Enter, add --use-existing-dir to the command, so it looks something like this:
$ bzr push lp:~your-username/project-name/branch-name --use-existing-dir
Note: You only need to add use-existing-dir the first time that you push to a newly registered branch.
Bazaar will now push your up to Launchpad. Give it a minute or two, then refresh your branch's overview page and you'll see the branch's most recent commits, as well as information about the format of your branch. Your branch is now public and anyone can make their own copy; only you can push changes to it and other people will have to upload their own version, just as you've done.
Pushing subsequent changes to Launchpad
Now, when you work on your code, all you need to do is commit changes to your local branch using bzr commit -m "Commit message".
You only need to push your changes up to Launchpad when you want to make them public.
Mirroring a branch that's hosted elsewhere
If you prefer to host your branch elsewhere, but still want to make it available in Launchpad, you can ask Launchpad to mirror it.
Setting up a branch mirror is similar to registering a hosted branch, except you supply the URL to your branch and Launchpad make regular copies.
If you need to work on the same branch of code with a group of people, you can create a team branch.