Sophie

Sophie

distrib > Fedora > 16 > i386 > by-pkgid > a99c463cccd19ab912401d5eb4e6ee20 > files > 501

bzr-doc-2.4.2-1.fc16.noarch.rpm



<!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="Content-Type" content="text/html; charset=utf-8" />
    
    <title>Undoing mistakes &mdash; Bazaar v2.4.2 documentation</title>
    <link rel="stylesheet" href="../_static/default.css" type="text/css" />
    <link rel="stylesheet" href="../_static/pygments.css" type="text/css" />
    <script type="text/javascript">
      var DOCUMENTATION_OPTIONS = {
        URL_ROOT:    '../',
        VERSION:     '2.4.2',
        COLLAPSE_INDEX: false,
        FILE_SUFFIX: '.html',
        HAS_SOURCE:  true
      };
    </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>
    <link rel="shortcut icon" href="../_static/bzr.ico"/>
    <link rel="top" title="Bazaar v2.4.2 documentation" href="../index.html" />
    <link rel="up" title="Bazaar User Guide" href="index.html" />
    <link rel="next" title="Working with another" href="partner_intro.html" />
    <link rel="prev" title="Releasing a project" href="releasing_a_project.html" /> 
  </head>
  <body>
    <div class="related">
      <h3>Navigation</h3>
      <ul>
        <li class="right" style="margin-right: 10px">
          <a href="partner_intro.html" title="Working with another"
             accesskey="N">next</a></li>
        <li class="right" >
          <a href="releasing_a_project.html" title="Releasing a project"
             accesskey="P">previous</a> |</li>
<li><a href="http://bazaar.canonical.com/">
    <img src="../_static/bzr icon 16.png" /> Home</a>&nbsp;|&nbsp;</li>
<a href="http://doc.bazaar.canonical.com/en/">Documentation</a>&nbsp;|&nbsp;</li>

        <li><a href="../index.html">Table of Contents (2.4.2)</a> &raquo;</li>

          <li><a href="index.html" accesskey="U">Bazaar User Guide</a> &raquo;</li> 
      </ul>
    </div>  

    <div class="document">
      <div class="documentwrapper">
        <div class="bodywrapper">
          <div class="body">
            
  <div class="section" id="undoing-mistakes">
<h1>Undoing mistakes<a class="headerlink" href="#undoing-mistakes" title="Permalink to this headline">¶</a></h1>
<div class="section" id="mistakes-happen">
<h2>Mistakes happen<a class="headerlink" href="#mistakes-happen" title="Permalink to this headline">¶</a></h2>
<p>Bazaar has been designed to make it easy to
recover from mistakes as explained below.</p>
</div>
<div class="section" id="dropping-the-revision-history-for-a-project">
<h2>Dropping the revision history for a project<a class="headerlink" href="#dropping-the-revision-history-for-a-project" title="Permalink to this headline">¶</a></h2>
<p>If you accidentally put the wrong tree under version control, simply
delete the <tt class="docutils literal"><span class="pre">.bzr</span></tt> directory.</p>
</div>
<div class="section" id="deregistering-a-file-or-directory">
<h2>Deregistering a file or directory<a class="headerlink" href="#deregistering-a-file-or-directory" title="Permalink to this headline">¶</a></h2>
<p>If you accidentally register a file using <tt class="docutils literal"><span class="pre">add</span></tt> that you
don&#8217;t want version controlled, you can use the <tt class="docutils literal"><span class="pre">remove</span></tt>
command to tell Bazaar to forget about it.</p>
<p><tt class="docutils literal"><span class="pre">remove</span></tt> has been designed to <em>Do the Safe Thing</em> in
that it will not delete a modified file. For example:</p>
<div class="highlight-python"><pre>bzr add foo.html
(oops - didn't mean that)
bzr remove foo.html</pre>
</div>
<p>This will complain about the file being modified or unknown.
If you want to keep the file, use the <tt class="docutils literal"><span class="pre">--keep</span></tt> option.
Alternatively, if you want to delete the file, use the <tt class="docutils literal"><span class="pre">--force</span></tt> option.
For example:</p>
<div class="highlight-python"><pre>bzr add foo.html
(oops - didn't mean that)
bzr remove --keep foo.html
(foo.html left on disk, but deregistered)</pre>
</div>
<p>On the other hand, the unchanged <tt class="docutils literal"><span class="pre">TODO</span></tt> file is deregistered and
removed from disk without complaint in this example:</p>
<div class="highlight-python"><pre>bzr add TODO
bzr commit -m "added TODO"
(hack, hack, hack - but don't change TODO)
bzr remove TODO
(TODO file deleted)</pre>
</div>
<p>Note: If you delete a file using your file manager, IDE or via an operating
system command, the <tt class="docutils literal"><span class="pre">commit</span></tt> command will implicitly treat it as removed.</p>
</div>
<div class="section" id="undoing-changes-since-the-last-commit">
<h2>Undoing changes since the last commit<a class="headerlink" href="#undoing-changes-since-the-last-commit" title="Permalink to this headline">¶</a></h2>
<p>One of the reasons for using a version control tool is that it
lets you easily checkpoint good tree states while working. If you
decide that the changes you have made since the last <tt class="docutils literal"><span class="pre">commit</span></tt> ought
to be thrown away, the command to use is <tt class="docutils literal"><span class="pre">revert</span></tt> like this:</p>
<div class="highlight-python"><pre>bzr revert</pre>
</div>
<p>As a precaution, it is good practice to use <tt class="docutils literal"><span class="pre">bzr</span> <span class="pre">status</span></tt> and
<tt class="docutils literal"><span class="pre">bzr</span> <span class="pre">diff</span></tt> first to check that everything being thrown away
really ought to be.</p>
</div>
<div class="section" id="undoing-changes-to-a-file-since-the-last-commit">
<h2>Undoing changes to a file since the last commit<a class="headerlink" href="#undoing-changes-to-a-file-since-the-last-commit" title="Permalink to this headline">¶</a></h2>
<p>If you want to undo changes to a particular file since the last commit but
keep all the other changes in the tree, pass the filename as an argument
to <tt class="docutils literal"><span class="pre">revert</span></tt> like this:</p>
<div class="highlight-python"><pre>bzr revert foo.py</pre>
</div>
</div>
<div class="section" id="undoing-the-last-commit">
<h2>Undoing the last commit<a class="headerlink" href="#undoing-the-last-commit" title="Permalink to this headline">¶</a></h2>
<p>If you make a commit and really didn&#8217;t mean to, use the <tt class="docutils literal"><span class="pre">uncommit</span></tt> command
to undo it like this:</p>
<div class="highlight-python"><pre>bzr uncommit</pre>
</div>
<p>Unlike <tt class="docutils literal"><span class="pre">revert</span></tt>, <tt class="docutils literal"><span class="pre">uncommit</span></tt> leaves the content of your working tree
exactly as it is. That&#8217;s really handy if you make a commit and accidently
provide the wrong error message. For example:</p>
<div class="highlight-python"><pre>bzr commit -m "Fix bug #11"
(damn - wrong bug number)
bzr uncommit
bzr commit -m "Fix bug #1"</pre>
</div>
<p>Another common reason for undoing a commit is because you forgot to add
one or more files. Some users like to alias <tt class="docutils literal"><span class="pre">commit</span></tt> to <tt class="docutils literal"><span class="pre">commit</span> <span class="pre">--strict</span></tt>
so that commits fail if unknown files are found in the tree.</p>
<p>Note: While the <tt class="docutils literal"><span class="pre">merge</span></tt> command is not introduced until the next
chapter, it is worth noting now that <tt class="docutils literal"><span class="pre">uncommit</span></tt> restores any pending
merges. (Running <tt class="docutils literal"><span class="pre">bzr</span> <span class="pre">status</span></tt> after <tt class="docutils literal"><span class="pre">uncommit</span></tt> will show these.)
<tt class="docutils literal"><span class="pre">merge</span></tt> can also be used to effectively undo just a selected commit
earlier in history. For more information on <tt class="docutils literal"><span class="pre">merge</span></tt>, see
<a class="reference external" href="merging_changes.html">Merging changes</a> in the next chapter and the
Bazaar User Reference.</p>
</div>
<div class="section" id="undoing-multiple-commits">
<h2>Undoing multiple commits<a class="headerlink" href="#undoing-multiple-commits" title="Permalink to this headline">¶</a></h2>
<p>You can use the -r option to undo several commits like this:</p>
<div class="highlight-python"><pre>bzr uncommit -r -3</pre>
</div>
<p>If your reason for doing this is that you really want to
back out several changes, then be sure to remember that <tt class="docutils literal"><span class="pre">uncommit</span></tt>
does not change your working tree: you&#8217;ll probably need to run the
<tt class="docutils literal"><span class="pre">revert</span></tt> command as well to complete the task. In many cases though,
it&#8217;s arguably better to leave your history alone and add a new
revision reflecting the content of the last good state.</p>
</div>
<div class="section" id="reverting-to-the-state-of-an-earlier-version">
<h2>Reverting to the state of an earlier version<a class="headerlink" href="#reverting-to-the-state-of-an-earlier-version" title="Permalink to this headline">¶</a></h2>
<p>If you make an unwanted change but it doesn&#8217;t make sense to uncommit
it (because that code has been released to users say), you can use
<tt class="docutils literal"><span class="pre">revert</span></tt> to take your working tree back to the desired state.
For example:</p>
<div class="highlight-python"><pre>% bzr commit "Fix bug #5"
Committed revision 20.
(release the code)
(hmm - bad fix)
bzr revert -r 19
bzr commit -m "Backout fix for bug #5"</pre>
</div>
<p>This will change your entire tree back to the state as of revision 19,
which is probably only what you want if you haven&#8217;t made any new commits
since then. If you have, the <tt class="docutils literal"><span class="pre">revert</span></tt> would wipe them out as well. In that
case, you probably want to use <a class="reference external" href="adv_merging.html#reverse-cherrypicking">Reverse cherrypicking</a> instead to
back out the bad fix.</p>
<p>Note: As an alternative to using an absolute revision number (like 19), you can
specify one relative to the tip (-1) using a negative number like this:</p>
<div class="highlight-python"><pre>bzr revert -r -2</pre>
</div>
</div>
<div class="section" id="correcting-a-tag">
<h2>Correcting a tag<a class="headerlink" href="#correcting-a-tag" title="Permalink to this headline">¶</a></h2>
<p>If you have defined a tag prematurely, use the <tt class="docutils literal"><span class="pre">--force</span></tt> option of
the <tt class="docutils literal"><span class="pre">tag</span></tt> command to redefine it. For example:</p>
<div class="highlight-python"><pre>bzr tag 2.0-beta-1
(oops, we're not yet ready for that)
(make more commits to include more fixes)
bzr tag 2.0-beta-1 --force</pre>
</div>
</div>
<div class="section" id="clearing-a-tag">
<h2>Clearing a tag<a class="headerlink" href="#clearing-a-tag" title="Permalink to this headline">¶</a></h2>
<p>If you have defined a tag and no longer want it defined, use the
<tt class="docutils literal"><span class="pre">--delete</span></tt> option of the <tt class="docutils literal"><span class="pre">tag</span></tt> command to remove it. For example:</p>
<div class="highlight-python"><pre>bzr tag 2.0-beta-4
(oops, we're not releasing a 4th beta)
bzr tag 2.0-beta-4 --delete</pre>
</div>
</div>
</div>


          </div>
        </div>
      </div>
      <div class="sphinxsidebar">
        <div class="sphinxsidebarwrapper">
  <h3><a href="../index.html">Table Of Contents</a></h3>
  <ul>
<li><a class="reference internal" href="#">Undoing mistakes</a><ul>
<li><a class="reference internal" href="#mistakes-happen">Mistakes happen</a></li>
<li><a class="reference internal" href="#dropping-the-revision-history-for-a-project">Dropping the revision history for a project</a></li>
<li><a class="reference internal" href="#deregistering-a-file-or-directory">Deregistering a file or directory</a></li>
<li><a class="reference internal" href="#undoing-changes-since-the-last-commit">Undoing changes since the last commit</a></li>
<li><a class="reference internal" href="#undoing-changes-to-a-file-since-the-last-commit">Undoing changes to a file since the last commit</a></li>
<li><a class="reference internal" href="#undoing-the-last-commit">Undoing the last commit</a></li>
<li><a class="reference internal" href="#undoing-multiple-commits">Undoing multiple commits</a></li>
<li><a class="reference internal" href="#reverting-to-the-state-of-an-earlier-version">Reverting to the state of an earlier version</a></li>
<li><a class="reference internal" href="#correcting-a-tag">Correcting a tag</a></li>
<li><a class="reference internal" href="#clearing-a-tag">Clearing a tag</a></li>
</ul>
</li>
</ul>

  <h4>Previous topic</h4>
  <p class="topless"><a href="releasing_a_project.html"
                        title="previous chapter">Releasing a project</a></p>
  <h4>Next topic</h4>
  <p class="topless"><a href="partner_intro.html"
                        title="next chapter">Working with another</a></p>
  <h3>This Page</h3>
  <ul class="this-page-menu">
    <li><a href="../_sources/user-guide/undoing_mistakes.txt"
           rel="nofollow">Show Source</a></li>
  </ul>
<div id="searchbox" style="display: none">
  <h3>Quick search</h3>
    <form class="search" action="../search.html" method="get">
      <input type="text" name="q" size="18" />
      <input type="submit" value="Go" />
      <input type="hidden" name="check_keywords" value="yes" />
      <input type="hidden" name="area" value="default" />
    </form>
    <p class="searchtip" style="font-size: 90%">
    Enter search terms or a module, class or function name.
    </p>
</div>
<script type="text/javascript">$('#searchbox').show(0);</script>
        </div>
      </div>
      <div class="clearer"></div>
    </div>
    <div class="related">
      <h3>Navigation</h3>
      <ul>
        <li class="right" style="margin-right: 10px">
          <a href="partner_intro.html" title="Working with another"
             >next</a></li>
        <li class="right" >
          <a href="releasing_a_project.html" title="Releasing a project"
             >previous</a> |</li>
<li><a href="http://bazaar.canonical.com/">
    <img src="../_static/bzr icon 16.png" /> Home</a>&nbsp;|&nbsp;</li>
<a href="http://doc.bazaar.canonical.com/en/">Documentation</a>&nbsp;|&nbsp;</li>

        <li><a href="../index.html">Table of Contents (2.4.2)</a> &raquo;</li>

          <li><a href="index.html" >Bazaar User Guide</a> &raquo;</li> 
      </ul>
    </div>
    <div class="footer">
        &copy; Copyright 2009-2011 Canonical Ltd.
      Created using <a href="http://sphinx.pocoo.org/">Sphinx</a> 1.0.7.
    </div>
  </body>
</html>