The purpose of the branch
command is to create a new branch based on another branch. Since Bazaar stores branches in separate directories, new branches are created in a new directory.
When used without additional parameters, the command creates a perfect replica of the source branch, copying its complete revision history. As each branch exists in its own directory in the filesystem, this is a good way of separating working environments right before starting to work on a feature branch as in the basic example earlier.
When creating the new directory for the new branch, by default Bazaar also creates a working tree. That is, the directory of the branch is populated with the project's files as of the latest or the specified revision. Note, however, that ignored files and pending changes in the source branch will not be copied, as they are not under version control.
It is often useful to create a branch that contains only the revisions up until the specified revision, instead of cloning all the revisions in the source branch. For example, when you realize that your recent changes have destabilized the project and you would like to try a different approach based on the last stable point.
To create a branch based on an older revision of another branch, specify the revision number with the -r
or --revision
flags. For example:
$ cd /sandbox/hello $ bzr branch -r3 trunk try-different Branched 3 revisions.
The second parameter is the name of the directory in which we create the new branch.
When the source branch is in a different parent directory or if it is a remote branch as in our first example earlier, then the second parameter becomes optional. In this case, Bazaar will use the last path segment of the URL as the name for the new branch as a sensible default. For example, the command bzr branch http://example.com/branches/test1
without a second parameter will create the new branch in a subdirectory called test1
, unless of course such a subdirectory already exists locally.
3.133.124.21