Autogenerated HTML docs for v1.3.0-g85e6
[git.git] / git-checkout.html
index 5c06d7a..d8ec484 100644 (file)
@@ -3,7 +3,7 @@
 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">\r
 <head>\r
 <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />\r
-<meta name="generator" content="AsciiDoc 7.0.1" />\r
+<meta name="generator" content="AsciiDoc 7.0.2" />\r
 <style type="text/css">\r
 /* Debug borders */\r
 p, li, dt, dd, div, pre, h1, h2, h3, h4, h5, h6 {\r
@@ -266,20 +266,23 @@ git-checkout(1) Manual Page
 <h2>NAME</h2>\r
 <div class="sectionbody">\r
 <p>git-checkout -\r
-   Checkout and switch to a branch.\r
+   Checkout and switch to a branch\r
 </p>\r
 </div>\r
 </div>\r
 <h2>SYNOPSIS</h2>\r
 <div class="sectionbody">\r
-<p><em>git-checkout</em> [-f] [-b &lt;new_branch&gt;] [&lt;branch&gt;] [&lt;paths&gt;&#8230;]</p>\r
+<div class="verseblock">\r
+<div class="content"><em>git-checkout</em> [-f] [-b &lt;new_branch&gt;] [-m] [&lt;branch&gt;]\r
+<em>git-checkout</em> [-m] [&lt;branch&gt;] &lt;paths&gt;&#8230;</div></div>\r
 </div>\r
 <h2>DESCRIPTION</h2>\r
 <div class="sectionbody">\r
-<p>When &lt;paths&gt; are not given, this command switches branches, by\r
+<p>When &lt;paths&gt; are not given, this command switches branches by\r
 updating the index and working tree to reflect the specified\r
 branch, &lt;branch&gt;, and updating HEAD to be &lt;branch&gt; or, if\r
-specified, &lt;new_branch&gt;.</p>\r
+specified, &lt;new_branch&gt;.  Using -b will cause &lt;new_branch&gt; to\r
+be created.</p>\r
 <p>When &lt;paths&gt; are given, this command does <strong>not</strong> switch\r
 branches.  It updates the named paths in the working tree from\r
 the index file (i.e. it runs <tt>git-checkout-index -f -u</tt>).  In\r
@@ -296,7 +299,7 @@ given paths before updating the working tree.</p>
 </dt>\r
 <dd>\r
 <p>\r
-        Force an re-read of everything.\r
+        Force a re-read of everything.\r
 </p>\r
 </dd>\r
 <dt>\r
@@ -308,6 +311,23 @@ given paths before updating the working tree.</p>
 </p>\r
 </dd>\r
 <dt>\r
+-m\r
+</dt>\r
+<dd>\r
+<p>\r
+        If you have local modifications to one or more files that\r
+        are different between the current branch and the branch to\r
+        which you are switching, the command refuses to switch\r
+        branches in order to preserve your modifications in context.\r
+        However, with this option, a three-way merge between the current\r
+        branch, your working tree contents, and the new branch\r
+        is done, and you will be on the new branch.\r
+</p>\r
+<p>When a merge conflict happens, the index entries for conflicting\r
+paths are left unmerged, and you need to resolve the conflicts\r
+and mark the resolved paths with <tt>git update-index</tt>.</p>\r
+</dd>\r
+<dt>\r
 &lt;new_branch&gt;\r
 </dt>\r
 <dd>\r
@@ -326,11 +346,15 @@ given paths before updating the working tree.</p>
 </dd>\r
 </dl>\r
 </div>\r
-<h2>EXAMPLE</h2>\r
+<h2>EXAMPLES</h2>\r
 <div class="sectionbody">\r
-<p>The following sequence checks out the <tt>master</tt> branch, reverts\r
+<ol>\r
+<li>\r
+<p>\r
+The following sequence checks out the <tt>master</tt> branch, reverts\r
 the <tt>Makefile</tt> to two revisions back, deletes hello.c by\r
-mistake, and gets it back from the index.</p>\r
+mistake, and gets it back from the index.\r
+</p>\r
 <div class="listingblock">\r
 <div class="content">\r
 <pre><tt>$ git checkout master <b>(1)</b>\r
@@ -349,6 +373,59 @@ that branch.  You should instead write:</p>
 <div class="content">\r
 <pre><tt>$ git checkout -- hello.c</tt></pre>\r
 </div></div>\r
+</li>\r
+<li>\r
+<p>\r
+After working in a wrong branch, switching to the correct\r
+branch would be done using:\r
+</p>\r
+<div class="listingblock">\r
+<div class="content">\r
+<pre><tt>$ git checkout mytopic</tt></pre>\r
+</div></div>\r
+<p>However, your "wrong" branch and correct "mytopic" branch may\r
+differ in files that you have locally modified, in which case,\r
+the above checkout would fail like this:</p>\r
+<div class="listingblock">\r
+<div class="content">\r
+<pre><tt>$ git checkout mytopic\r
+fatal: Entry 'frotz' not uptodate. Cannot merge.</tt></pre>\r
+</div></div>\r
+<p>You can give the <tt>-m</tt> flag to the command, which would try a\r
+three-way merge:</p>\r
+<div class="listingblock">\r
+<div class="content">\r
+<pre><tt>$ git checkout -m mytopic\r
+Auto-merging frotz</tt></pre>\r
+</div></div>\r
+<p>After this three-way merge, the local modifications are _not_\r
+registered in your index file, so <tt>git diff</tt> would show you what\r
+changes you made since the tip of the new branch.</p>\r
+</li>\r
+<li>\r
+<p>\r
+When a merge conflict happens during switching branches with\r
+the <tt>-m</tt> option, you would see something like this:\r
+</p>\r
+<div class="listingblock">\r
+<div class="content">\r
+<pre><tt>$ git checkout -m mytopic\r
+Auto-merging frotz\r
+merge: warning: conflicts during merge\r
+ERROR: Merge conflict in frotz\r
+fatal: merge program failed</tt></pre>\r
+</div></div>\r
+<p>At this point, <tt>git diff</tt> shows the changes cleanly merged as in\r
+the previous example, as well as the changes in the conflicted\r
+files.  Edit and resolve the conflict and mark it resolved with\r
+<tt>git update-index</tt> as usual:</p>\r
+<div class="listingblock">\r
+<div class="content">\r
+<pre><tt>$ edit frotz\r
+$ git update-index frotz</tt></pre>\r
+</div></div>\r
+</li>\r
+</ol>\r
 </div>\r
 <h2>Author</h2>\r
 <div class="sectionbody">\r
@@ -364,7 +441,7 @@ that branch.  You should instead write:</p>
 </div>\r
 <div id="footer">\r
 <div id="footer-text">\r
-Last updated 27-Dec-2005 00:15:51 PDT\r
+Last updated 18-Mar-2006 07:45:34 UTC\r
 </div>\r
 </div>\r
 </body>\r