Local branches with a bazaar?

I recently talked to Git to get an idea of ​​distributed version control. Now I look at Bazaar, but I can’t figure out how to create a local branch, i.e. A branch that I don’t need to click on when I want to make changes. With Git, I would do

git branch branch_name

or

git checkout -b branch_name

Then I can work in my local branch, making changes when I go, without having to make changes to the remote repo. When I’ve finished working with a branch, I can combine it with my local master branch. If I want, I can then make these changes to the remote repo.

Is this possible with Bazaar? Bazaar seems to be more like SVN, and branches are just separate directories, so maybe not.

+2
source share
4 answers

Yes, you can definitely do it.

Say there is a remote repository in 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 local_branch and commit them, and these changes are only in this local directory. eg:.

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

This will add foo only to the local branch.

+4
source

If you configured your repository correctly, you can work similarly 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 this:

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

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

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

and now you will be taken to some-feature branch, which will be at the same point as mainline.

+3
source

bzr differs from git in that you cannot switch the branch represented by the working directory. You can branch from your working directory, but instead of having a branch from a remote repository. Therefore, instead of

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

would you do

 bzr branch bzr+ssh://foo.com/repo bzr branch repo new_branch 
+2
source

An old question, but it seems that colocated branches are the way to this for now. Bzr includes a plugin with various convenience features, including colo-init for creating repositories with linking enabled and colo-branch for actual use / creating branches (I haven't used these features yet, so maybe this was a bit mixed up.)

+2
source

Source: https://habr.com/ru/post/1316203/


All Articles