<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="X-UA-Compatible" content="IE=Edge" /> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Organizing branches — Bazaar 2.7.0 documentation</title> <link rel="stylesheet" href="../_static/classic.css" type="text/css" /> <link rel="stylesheet" href="../_static/pygments.css" type="text/css" /> <script type="text/javascript" id="documentation_options" data-url_root="../" src="../_static/documentation_options.js"></script> <script type="text/javascript" src="../_static/jquery.js"></script> <script type="text/javascript" src="../_static/underscore.js"></script> <script type="text/javascript" src="../_static/doctools.js"></script> <script type="text/javascript" src="../_static/language_data.js"></script> <link rel="shortcut icon" href="../_static/bzr.ico"/> <link rel="search" title="Search" href="../search.html" /> <link rel="next" title="Using gatekeepers" href="using_gatekeepers.html" /> <link rel="prev" title="Distributed development" href="distributed_intro.html" /> </head><body> <div class="related" role="navigation" aria-label="related navigation"> <h3>Navigation</h3> <ul> <li class="right" style="margin-right: 10px"> <a href="using_gatekeepers.html" title="Using gatekeepers" accesskey="N">next</a></li> <li class="right" > <a href="distributed_intro.html" title="Distributed development" accesskey="P">previous</a> |</li> <li><a href="http://bazaar.canonical.com/"> <img src="../_static/bzr icon 16.png" /> Home</a> | </li> <a href="http://doc.bazaar.canonical.com/en/">Documentation</a> | </li> <li class="nav-item nav-item-0"><a href="../index.html">Table of Contents (2.7.0)</a> »</li> <li class="nav-item nav-item-1"><a href="index.html" accesskey="U">Bazaar User Guide</a> »</li> </ul> </div> <div class="document"> <div class="documentwrapper"> <div class="bodywrapper"> <div class="body" role="main"> <div class="section" id="organizing-branches"> <h1>Organizing branches<a class="headerlink" href="#organizing-branches" title="Permalink to this headline">¶</a></h1> <div class="section" id="mirror-branches"> <h2>Mirror branches<a class="headerlink" href="#mirror-branches" title="Permalink to this headline">¶</a></h2> <p>A primary difference when using distributed workflows to develop is that your main local branch is not the place to make changes. Instead, it is kept as a pristine copy of the central branch, i.e. it’s a <em>mirror branch</em>.</p> <p>To create a mirror branch, set-up a shared repository (if you haven’t already) and then use the <code class="docutils literal notranslate"><span class="pre">branch</span></code> (or <code class="docutils literal notranslate"><span class="pre">checkout</span></code>) command to create the mirror. For example:</p> <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">bzr</span> <span class="n">init</span><span class="o">-</span><span class="n">repo</span> <span class="n">PROJECT</span> <span class="n">cd</span> <span class="n">PROJECT</span> <span class="n">bzr</span> <span class="n">branch</span> <span class="n">bzr</span><span class="o">+</span><span class="n">ssh</span><span class="p">:</span><span class="o">//</span><span class="n">centralhost</span><span class="o">/</span><span class="n">srv</span><span class="o">/</span><span class="n">bzr</span><span class="o">/</span><span class="n">PROJECT</span><span class="o">/</span><span class="n">trunk</span> </pre></div> </div> </div> <div class="section" id="task-branches"> <h2>Task branches<a class="headerlink" href="#task-branches" title="Permalink to this headline">¶</a></h2> <p>Each new feature or fix is developed in its own branch. These branches are referred to as <em>feature branches</em> or <em>task branches</em> - the terms are used interchangeably.</p> <p>To create a task branch, use the <code class="docutils literal notranslate"><span class="pre">branch</span></code> command against your mirror branch. For example:</p> <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">bzr</span> <span class="n">branch</span> <span class="n">trunk</span> <span class="n">fix</span><span class="o">-</span><span class="mi">123</span> <span class="n">cd</span> <span class="n">fix</span><span class="o">-</span><span class="mi">123</span> <span class="p">(</span><span class="n">hack</span><span class="p">,</span> <span class="n">hack</span><span class="p">,</span> <span class="n">hack</span><span class="p">)</span> </pre></div> </div> <p>There are numerous advantages to this approach:</p> <blockquote> <div><ol class="arabic simple"> <li>You can work on multiple changes in parallel</li> <li>There is reduced coupling between changes</li> <li>Multiple people can work in a peer-to-peer mode on a branch until it is ready to go.</li> </ol> </div></blockquote> <p>In particular, some changes take longer to cook than others so you can ask for reviews, apply feedback, ask for another review, etc. By completing work to sufficient quality in separate branches before merging into a central branch, the quality and stability of the central branch are maintained at higher level than they otherwise would be.</p> </div> <div class="section" id="refreshing-a-mirror-branch"> <h2>Refreshing a mirror branch<a class="headerlink" href="#refreshing-a-mirror-branch" title="Permalink to this headline">¶</a></h2> <p>Use the <code class="docutils literal notranslate"><span class="pre">pull</span></code> command to do this:</p> <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">cd</span> <span class="n">trunk</span> <span class="n">bzr</span> <span class="n">pull</span> </pre></div> </div> </div> <div class="section" id="merging-the-latest-trunk-into-a-feature-branch"> <h2>Merging the latest trunk into a feature branch<a class="headerlink" href="#merging-the-latest-trunk-into-a-feature-branch" title="Permalink to this headline">¶</a></h2> <p>Use the <code class="docutils literal notranslate"><span class="pre">merge</span></code> command to do this:</p> <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">cd</span> <span class="n">fix</span><span class="o">-</span><span class="mi">123</span> <span class="n">bzr</span> <span class="n">merge</span> <span class="p">(</span><span class="n">resolve</span> <span class="nb">any</span> <span class="n">conflicts</span><span class="p">)</span> <span class="n">bzr</span> <span class="n">commit</span> <span class="o">-</span><span class="n">m</span> <span class="s2">"merged trunk"</span> </pre></div> </div> </div> <div class="section" id="merging-a-feature-into-the-trunk"> <h2>Merging a feature into the trunk<a class="headerlink" href="#merging-a-feature-into-the-trunk" title="Permalink to this headline">¶</a></h2> <p>The policies for different distributed workflows vary here. The simple case where all developers have commit rights to the main trunk are shown below.</p> <p>If your mirror is a checkout:</p> <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">cd</span> <span class="n">trunk</span> <span class="n">bzr</span> <span class="n">update</span> <span class="n">bzr</span> <span class="n">merge</span> <span class="o">../</span><span class="n">fix</span><span class="o">-</span><span class="mi">123</span> <span class="p">(</span><span class="n">resolve</span> <span class="nb">any</span> <span class="n">conflicts</span><span class="p">)</span> <span class="n">bzr</span> <span class="n">commit</span> <span class="o">-</span><span class="n">m</span> <span class="s2">"Fixed bug #123"</span> </pre></div> </div> <p>If your mirror is a branch:</p> <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">cd</span> <span class="n">trunk</span> <span class="n">bzr</span> <span class="n">pull</span> <span class="n">bzr</span> <span class="n">merge</span> <span class="o">../</span><span class="n">fix</span><span class="o">-</span><span class="mi">123</span> <span class="p">(</span><span class="n">resolve</span> <span class="nb">any</span> <span class="n">conflicts</span><span class="p">)</span> <span class="n">bzr</span> <span class="n">commit</span> <span class="o">-</span><span class="n">m</span> <span class="s2">"Fixed bug #123"</span> <span class="n">bzr</span> <span class="n">push</span> </pre></div> </div> </div> <div class="section" id="backing-up-task-branches"> <h2>Backing up task branches<a class="headerlink" href="#backing-up-task-branches" title="Permalink to this headline">¶</a></h2> <p>One of the side effects of centralized workflows is that changes get frequently committed to a central location which is backed up as part of normal IT operations. When developing on task branches, it is a good idea to publish your work to a central location (but not necessarily a shared location) that will be backed up. You may even wish to bind local task branches to remote ones established on a backup server just for this purpose.</p> </div> </div> </div> </div> </div> <div class="sphinxsidebar" role="navigation" aria-label="main navigation"> <div class="sphinxsidebarwrapper"> <h3><a href="../index.html">Table of Contents</a></h3> <ul> <li><a class="reference internal" href="#">Organizing branches</a><ul> <li><a class="reference internal" href="#mirror-branches">Mirror branches</a></li> <li><a class="reference internal" href="#task-branches">Task branches</a></li> <li><a class="reference internal" href="#refreshing-a-mirror-branch">Refreshing a mirror branch</a></li> <li><a class="reference internal" href="#merging-the-latest-trunk-into-a-feature-branch">Merging the latest trunk into a feature branch</a></li> <li><a class="reference internal" href="#merging-a-feature-into-the-trunk">Merging a feature into the trunk</a></li> <li><a class="reference internal" href="#backing-up-task-branches">Backing up task branches</a></li> </ul> </li> </ul> <h4>Previous topic</h4> <p class="topless"><a href="distributed_intro.html" title="previous chapter">Distributed development</a></p> <h4>Next topic</h4> <p class="topless"><a href="using_gatekeepers.html" title="next chapter">Using gatekeepers</a></p> <div role="note" aria-label="source link"> <h3>This Page</h3> <ul class="this-page-menu"> <li><a href="../_sources/user-guide/organizing_branches.txt" rel="nofollow">Show Source</a></li> </ul> </div> <div id="searchbox" style="display: none" role="search"> <h3>Quick search</h3> <div class="searchformwrapper"> <form class="search" action="../search.html" method="get"> <input type="text" name="q" /> <input type="submit" value="Go" /> <input type="hidden" name="check_keywords" value="yes" /> <input type="hidden" name="area" value="default" /> </form> </div> </div> <script type="text/javascript">$('#searchbox').show(0);</script> </div> </div> <div class="clearer"></div> </div> <div class="related" role="navigation" aria-label="related navigation"> <h3>Navigation</h3> <ul> <li class="right" style="margin-right: 10px"> <a href="using_gatekeepers.html" title="Using gatekeepers" >next</a></li> <li class="right" > <a href="distributed_intro.html" title="Distributed development" >previous</a> |</li> <li><a href="http://bazaar.canonical.com/"> <img src="../_static/bzr icon 16.png" /> Home</a> | </li> <a href="http://doc.bazaar.canonical.com/en/">Documentation</a> | </li> <li class="nav-item nav-item-0"><a href="../index.html">Table of Contents (2.7.0)</a> »</li> <li class="nav-item nav-item-1"><a href="index.html" >Bazaar User Guide</a> »</li> </ul> </div> <div class="footer" role="contentinfo"> © Copyright 2009-2011 Canonical Ltd. Created using <a href="http://sphinx-doc.org/">Sphinx</a> 1.8.4. </div> </body> </html>