Creating branches on a server works much in the same way as when creating branches locally. Here, we emphasize on some good practices for optimal performance.
The same way as when working with local branches, it is a good idea to create a shared repository per project to host multiple Bazaar branches. Even if you don't intend to use multiple branches at first, you might want to do that later, and it is easier to have a shared repository right from the start, than migrating an existing branch later.
Another important point is to configure the shared repository to not create working trees by default. Working trees are unnecessary on the server, because collaborators work in their local checkouts, and Bazaar may give warnings during branch operations if the central branch contains a working tree. In order to avoid confusion, it is better to completely omit working trees on the server.
Similar to when working with local branches, using a shared repository on the server is a good way to save disk space. In addition, when pushing a new branch to the server that shares revisions with an existing branch, the shared revisions don't need to be copied, thus the push operation will be faster.
When creating the shared repository, make sure to use the --no-trees
flag, so that new branches will be created without trees by default. Although, most probably, you will create new branches using push
operations, and most protocols don't support creating a working tree when used with push, nonetheless it is a good precaution to set up a shared repository in this way right from the start.
You can use the bzr info
command to check whether a shared repository is configured with or without working trees. For example:
$ bzr info bzr+ssh://[email protected]/tmp/repo/ Shared repository with trees (format: unnamed) Location: shared repository: bzr+ssh://[email protected]/tmp/repo/
If the first line of the output says Shared repository with trees
instead of simply Shared repository
, then you should log in to the server and reconfigure it by using the bzr reconfigure
command with the --with-no-trees
flag. For example:
$ cd /tmp/repo $ bzr reconfigure --with-no-trees $ bzr info Shared repository (format: 2a) Location: shared repository: .
If you already have branches on the central server with a working tree, then it is a good idea to remove them.
First, check the status of the working tree by using the bzr status
command. If there are any pending changes, then commit or revert them.
To remove the working tree, use the
bzr reconfigure
command with the --branch
flag.
Although you can use the bzr init
and bzr branch
commands directly on the server in the same way as you would do it locally, it would defeat the purpose of the centralized setup, and invite mistakes such as creating working trees by accident.
A common way to create new branches on the server is by using a push operation from your local branch. For example:
$ bzr push bzr+ssh://[email protected]/tmp/repo/branch1 Created new branch.
After pushing a branch, if you would like to work on it in the centralized mode, then you can bind to the remote branch by using the :push
location alias:
$ bzr bind :push
3.137.184.3