Local branches with Bazaar?

守給你的承諾、 提交于 2019-12-04 17:55:30

Yes, you definitely can do that.

Let's say there's a remote repository at bzr+ssh://foo.com/repo/mainline

You can create a local branch by doing:

bzr branch bzr+ssh://foo.com/repo/mainline local_branch

Now, you can make changes to the local_branch and commit them, and those changes are only in that local directory. e.g.:

cd local_branch
touch foo
bzr add foo
bzr commit -m "Add foo."

That will add foo only in the local branch.

If you set up your repository the correct way, you can work in a similar fashion to git.

cd ~/dev
bzr init-repo
bzr reconfigure --with-no-trees
mkdir branches
bzr branch bzr+ssh://foo.com/repo branches/mainline
bzr checkout --lightweight branches/mainline working

This will create a structure like so:

/dev
    /branches
        /mainline
        <other branches go here>
    /working
        <this is your working tree>

And if you want to make branches, you can do the following:

cd ~/dev/checkout
bzr branch --switch ~/dev/branches/mainline ~/dev/branches/some-feature

and now you'll be in the some-feature branch, which will be at the same point as mainline.

Old question, but it appears that colocated branches are the way to go for this nowadays. Bzr includes a plugin with various convenience functions, including colo-init for creating colocated-branch-enabled repositories and colo-branch for actually using/creating branches (I have not made extensive use of these features yet, so I may have this a bit jumbled..)

bzr differs from git in that you can't switch the branch represented by the working directory. You can branch from your working directory, though, instead of having to branch from the remote repository. So instead of

git clone git+ssh://foo.com/repo
cd repo
git checkout -b new_branch

you would do

bzr branch bzr+ssh://foo.com/repo
bzr branch repo new_branch
标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!