Search code examples
version-controlbranchbazaartortoisebzr

Should I use push or switch to create branch in bazaar?


To create a branch in bazaar, I can do two things:

  • Checkout the trunck, do modifications, local commit and then push my version to MyProject/MyBranch

or

  • create MyProject/MyBranch and switch my checkout to the new branch, then do modification and commit.

My questions:

  • Does this two operations produce the same result ?
  • What is the best pratices about branch ?

Solution

  • I wasn't sure what would happen when a checkout with local commits was pushed, so I tried it out.

    It turns out that in both cases, you'll end up with history like:

    trunk:

    1. old commit
    2. etc.

    branch:

    1. new commit
    2. old commit
    3. etc.

    However, branching first and working with a checkout of the branch is a much better way to do it. If you have a checkout with local commits and do a bzr update you won't be able to bzr push before committing.

    Secondly, if you have a checkout of the trunk with local commits, 'bzr push' to create the branch, then try to 'bzr switch` to the branch, you first have to commit or revert to avoid the "Cannot switch as local commits found in the checkout" error.