summaryrefslogtreecommitdiffstats
path: root/git-checkout.html
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2019-07-09 19:54:04 -0700
committerJunio C Hamano <gitster@pobox.com>2019-07-09 19:54:04 -0700
commitc9f11c2b3a739e3e249b9e7711bf1ed76ef3c6db (patch)
tree06ddfc72dff8e370e395a3acc692c8ab48147227 /git-checkout.html
parentd0a9940c76b71c9df840a098a423d3400779d83c (diff)
downloadgit-htmldocs-c9f11c2b3a739e3e249b9e7711bf1ed76ef3c6db.tar.gz
Autogenerated HTML docs for v2.22.0-428-g6d5b2
Diffstat (limited to 'git-checkout.html')
-rw-r--r--git-checkout.html242
1 files changed, 140 insertions, 102 deletions
diff --git a/git-checkout.html b/git-checkout.html
index 668d10cf9..1013dcbb5 100644
--- a/git-checkout.html
+++ b/git-checkout.html
@@ -769,32 +769,24 @@ also update <code>HEAD</code> to set the specified branch as the current
branch.</p></div>
<div class="dlist"><dl>
<dt class="hdlist1">
-<em>git checkout</em> &lt;branch&gt;
+<em>git checkout</em> [&lt;branch&gt;]
</dt>
<dd>
<p>
- To prepare for working on &lt;branch&gt;, switch to it by updating
+ To prepare for working on <code>&lt;branch&gt;</code>, switch to it by updating
the index and the files in the working tree, and by pointing
- HEAD at the branch. Local modifications to the files in the
+ <code>HEAD</code> at the branch. Local modifications to the files in the
working tree are kept, so that they can be committed to the
- &lt;branch&gt;.
+ <code>&lt;branch&gt;</code>.
</p>
-<div class="paragraph"><p>If &lt;branch&gt; is not found but there does exist a tracking branch in
-exactly one remote (call it &lt;remote&gt;) with a matching name, treat as
-equivalent to</p></div>
+<div class="paragraph"><p>If <code>&lt;branch&gt;</code> is not found but there does exist a tracking branch in
+exactly one remote (call it <code>&lt;remote&gt;</code>) with a matching name and
+<code>--no-guess</code> is not specified, treat as equivalent to</p></div>
<div class="listingblock">
<div class="content">
<pre><code>$ git checkout -b &lt;branch&gt; --track &lt;remote&gt;/&lt;branch&gt;</code></pre>
</div></div>
-<div class="paragraph"><p>If the branch exists in multiple remotes and one of them is named by
-the <code>checkout.defaultRemote</code> configuration variable, we&#8217;ll use that
-one for the purposes of disambiguation, even if the <code>&lt;branch&gt;</code> isn&#8217;t
-unique across all remotes. Set it to
-e.g. <code>checkout.defaultRemote=origin</code> to always checkout remote
-branches from there if <code>&lt;branch&gt;</code> is ambiguous but exists on the
-<em>origin</em> remote. See also <code>checkout.defaultRemote</code> in
-<a href="git-config.html">git-config(1)</a>.</p></div>
-<div class="paragraph"><p>You could omit &lt;branch&gt;, in which case the command degenerates to
+<div class="paragraph"><p>You could omit <code>&lt;branch&gt;</code>, in which case the command degenerates to
"check out the current branch", which is a glorified no-op with
rather expensive side-effects to show only the tracking information,
if exists, for the current branch.</p></div>
@@ -811,7 +803,7 @@ if exists, for the current branch.</p></div>
<code>--track</code> without <code>-b</code> implies branch creation; see the
description of <code>--track</code> below.
</p>
-<div class="paragraph"><p>If <code>-B</code> is given, &lt;new_branch&gt; is created if it doesn&#8217;t exist; otherwise, it
+<div class="paragraph"><p>If <code>-B</code> is given, <code>&lt;new_branch&gt;</code> is created if it doesn&#8217;t exist; otherwise, it
is reset. This is the transactional equivalent of</p></div>
<div class="listingblock">
<div class="content">
@@ -829,17 +821,17 @@ successful.</p></div>
</dt>
<dd>
<p>
- Prepare to work on top of &lt;commit&gt;, by detaching HEAD at it
+ Prepare to work on top of <code>&lt;commit&gt;</code>, by detaching <code>HEAD</code> at it
(see "DETACHED HEAD" section), and updating the index and the
files in the working tree. Local modifications to the files
in the working tree are kept, so that the resulting working
tree will be the state recorded in the commit plus the local
modifications.
</p>
-<div class="paragraph"><p>When the &lt;commit&gt; argument is a branch name, the <code>--detach</code> option can
-be used to detach HEAD at the tip of the branch (<code>git checkout
-&lt;branch&gt;</code> would check out that branch without detaching HEAD).</p></div>
-<div class="paragraph"><p>Omitting &lt;branch&gt; detaches HEAD at the tip of the current branch.</p></div>
+<div class="paragraph"><p>When the <code>&lt;commit&gt;</code> argument is a branch name, the <code>--detach</code> option can
+be used to detach <code>HEAD</code> at the tip of the branch (<code>git checkout
+&lt;branch&gt;</code> would check out that branch without detaching <code>HEAD</code>).</p></div>
+<div class="paragraph"><p>Omitting <code>&lt;branch&gt;</code> detaches <code>HEAD</code> at the tip of the current branch.</p></div>
</dd>
<dt class="hdlist1">
<em>git checkout</em> [&lt;tree-ish&gt;] [--] &lt;pathspec&gt;&#8230;
@@ -847,9 +839,9 @@ be used to detach HEAD at the tip of the branch (<code>git checkout
<dd>
<p>
Overwrite paths in the working tree by replacing with the
- contents in the index or in the &lt;tree-ish&gt; (most often a
- commit). When a &lt;tree-ish&gt; is given, the paths that
- match the &lt;pathspec&gt; are updated both in the index and in
+ contents in the index or in the <code>&lt;tree-ish&gt;</code> (most often a
+ commit). When a <code>&lt;tree-ish&gt;</code> is given, the paths that
+ match the <code>&lt;pathspec&gt;</code> are updated both in the index and in
the working tree.
</p>
<div class="paragraph"><p>The index may contain unmerged entries because of a previous failed merge.
@@ -891,7 +883,10 @@ file can be discarded to re-create the original conflicted merge result.</p></di
</p>
</dd>
<dt class="hdlist1">
---[no-]progress
+--progress
+</dt>
+<dt class="hdlist1">
+--no-progress
</dt>
<dd>
<p>
@@ -910,7 +905,7 @@ file can be discarded to re-create the original conflicted merge result.</p></di
<dd>
<p>
When switching branches, proceed even if the index or the
- working tree differs from HEAD. This is used to throw away
+ working tree differs from <code>HEAD</code>. This is used to throw away
local changes.
</p>
<div class="paragraph"><p>When checking out paths from the index, do not fail upon unmerged
@@ -946,8 +941,8 @@ of it").</p></div>
</dt>
<dd>
<p>
- Create a new branch named &lt;new_branch&gt; and start it at
- &lt;start_point&gt;; see <a href="git-branch.html">git-branch(1)</a> for details.
+ Create a new branch named <code>&lt;new_branch&gt;</code> and start it at
+ <code>&lt;start_point&gt;</code>; see <a href="git-branch.html">git-branch(1)</a> for details.
</p>
</dd>
<dt class="hdlist1">
@@ -955,8 +950,8 @@ of it").</p></div>
</dt>
<dd>
<p>
- Creates the branch &lt;new_branch&gt; and start it at &lt;start_point&gt;;
- if it already exists, then reset it to &lt;start_point&gt;. This is
+ Creates the branch <code>&lt;new_branch&gt;</code> and start it at <code>&lt;start_point&gt;</code>;
+ if it already exists, then reset it to <code>&lt;start_point&gt;</code>. This is
equivalent to running "git branch" with "-f"; see
<a href="git-branch.html">git-branch(1)</a> for details.
</p>
@@ -976,9 +971,9 @@ of it").</p></div>
derived from the remote-tracking branch, by looking at the local part of
the refspec configured for the corresponding remote, and then stripping
the initial part up to the "*".
-This would tell us to use "hack" as the local branch when branching
-off of "origin/hack" (or "remotes/origin/hack", or even
-"refs/remotes/origin/hack"). If the given name has no slash, or the above
+This would tell us to use <code>hack</code> as the local branch when branching
+off of <code>origin/hack</code> (or <code>remotes/origin/hack</code>, or even
+<code>refs/remotes/origin/hack</code>). If the given name has no slash, or the above
guessing results in an empty name, the guessing is aborted. You can
explicitly give a name with <code>-b</code> in such a case.</p></div>
</dd>
@@ -988,10 +983,36 @@ explicitly give a name with <code>-b</code> in such a case.</p></div>
<dd>
<p>
Do not set up "upstream" configuration, even if the
- branch.autoSetupMerge configuration variable is true.
+ <code>branch.autoSetupMerge</code> configuration variable is true.
</p>
</dd>
<dt class="hdlist1">
+--guess
+</dt>
+<dt class="hdlist1">
+--no-guess
+</dt>
+<dd>
+<p>
+ If <code>&lt;branch&gt;</code> is not found but there does exist a tracking
+ branch in exactly one remote (call it <code>&lt;remote&gt;</code>) with a
+ matching name, treat as equivalent to
+</p>
+<div class="listingblock">
+<div class="content">
+<pre><code>$ git checkout -b &lt;branch&gt; --track &lt;remote&gt;/&lt;branch&gt;</code></pre>
+</div></div>
+<div class="paragraph"><p>If the branch exists in multiple remotes and one of them is named by
+the <code>checkout.defaultRemote</code> configuration variable, we&#8217;ll use that
+one for the purposes of disambiguation, even if the <code>&lt;branch&gt;</code> isn&#8217;t
+unique across all remotes. Set it to
+e.g. <code>checkout.defaultRemote=origin</code> to always checkout remote
+branches from there if <code>&lt;branch&gt;</code> is ambiguous but exists on the
+<em>origin</em> remote. See also <code>checkout.defaultRemote</code> in
+<a href="git-config.html">git-config(1)</a>.</p></div>
+<div class="paragraph"><p>Use <code>--no-guess</code> to disable this.</p></div>
+</dd>
+<dt class="hdlist1">
-l
</dt>
<dd>
@@ -1007,8 +1028,8 @@ explicitly give a name with <code>-b</code> in such a case.</p></div>
<p>
Rather than checking out a branch to work on it, check out a
commit for inspection and discardable experiments.
- This is the default behavior of "git checkout &lt;commit&gt;" when
- &lt;commit&gt; is not a branch name. See the "DETACHED HEAD" section
+ This is the default behavior of <code>git checkout &lt;commit&gt;</code> when
+ <code>&lt;commit&gt;</code> is not a branch name. See the "DETACHED HEAD" section
below for details.
</p>
</dd>
@@ -1017,25 +1038,25 @@ explicitly give a name with <code>-b</code> in such a case.</p></div>
</dt>
<dd>
<p>
- Create a new <em>orphan</em> branch, named &lt;new_branch&gt;, started from
- &lt;start_point&gt; and switch to it. The first commit made on this
+ Create a new <em>orphan</em> branch, named <code>&lt;new_branch&gt;</code>, started from
+ <code>&lt;start_point&gt;</code> and switch to it. The first commit made on this
new branch will have no parents and it will be the root of a new
history totally disconnected from all the other branches and
commits.
</p>
<div class="paragraph"><p>The index and the working tree are adjusted as if you had previously run
-"git checkout &lt;start_point&gt;". This allows you to start a new history
-that records a set of paths similar to &lt;start_point&gt; by easily running
-"git commit -a" to make the root commit.</p></div>
+<code>git checkout &lt;start_point&gt;</code>. This allows you to start a new history
+that records a set of paths similar to <code>&lt;start_point&gt;</code> by easily running
+<code>git commit -a</code> to make the root commit.</p></div>
<div class="paragraph"><p>This can be useful when you want to publish the tree from a commit
without exposing its full history. You might want to do this to publish
an open source branch of a project whose current tree is "clean", but
whose full history contains proprietary or otherwise encumbered bits of
code.</p></div>
<div class="paragraph"><p>If you want to start a disconnected history that records a set of paths
-that is totally different from the one of &lt;start_point&gt;, then you should
+that is totally different from the one of <code>&lt;start_point&gt;</code>, then you should
clear the index and the working tree right after creating the orphan
-branch by running "git rm -rf ." from the top level of the working tree.
+branch by running <code>git rm -rf .</code> from the top level of the working tree.
Afterwards you will be ready to prepare your new files, repopulating the
working tree, by copying them from elsewhere, extracting a tarball, etc.</p></div>
</dd>
@@ -1045,9 +1066,9 @@ working tree, by copying them from elsewhere, extracting a tarball, etc.</p></di
<dd>
<p>
In sparse checkout mode, <code>git checkout -- &lt;paths&gt;</code> would
- update only entries matched by &lt;paths&gt; and sparse patterns
- in $GIT_DIR/info/sparse-checkout. This option ignores
- the sparse patterns and adds back any files in &lt;paths&gt;.
+ update only entries matched by <code>&lt;paths&gt;</code> and sparse patterns
+ in <code>$GIT_DIR/info/sparse-checkout</code>. This option ignores
+ the sparse patterns and adds back any files in <code>&lt;paths&gt;</code>.
</p>
</dd>
<dt class="hdlist1">
@@ -1080,9 +1101,9 @@ the conflicted merge in the specified paths.</p></div>
</dt>
<dd>
<p>
- The same as --merge option above, but changes the way the
+ The same as <code>--merge</code> option above, but changes the way the
conflicting hunks are presented, overriding the
- merge.conflictStyle configuration variable. Possible values are
+ <code>merge.conflictStyle</code> configuration variable. Possible values are
"merge" (default) and "diff3" (in addition to what is shown by
"merge" style, shows the original contents).
</p>
@@ -1096,15 +1117,15 @@ the conflicted merge in the specified paths.</p></div>
<dd>
<p>
Interactively select hunks in the difference between the
- &lt;tree-ish&gt; (or the index, if unspecified) and the working
+ <code>&lt;tree-ish&gt;</code> (or the index, if unspecified) and the working
tree. The chosen hunks are then applied in reverse to the
- working tree (and if a &lt;tree-ish&gt; was specified, the index).
+ working tree (and if a <code>&lt;tree-ish&gt;</code> was specified, the index).
</p>
<div class="paragraph"><p>This means that you can use <code>git checkout -p</code> to selectively discard
edits from your current working tree. See the &#8220;Interactive Mode&#8221;
section of <a href="git-add.html">git-add(1)</a> to learn how to operate the <code>--patch</code> mode.</p></div>
<div class="paragraph"><p>Note that this option uses the no overlay mode by default (see also
-<code>--[no-]overlay</code>), and currently doesn&#8217;t support overlay mode.</p></div>
+<code>--overlay</code>), and currently doesn&#8217;t support overlay mode.</p></div>
</dd>
<dt class="hdlist1">
--ignore-other-worktrees
@@ -1118,38 +1139,48 @@ section of <a href="git-add.html">git-add(1)</a> to learn how to operate the <co
</p>
</dd>
<dt class="hdlist1">
---[no-]recurse-submodules
+--overwrite-ignore
+</dt>
+<dt class="hdlist1">
+--no-overwrite-ignore
</dt>
<dd>
<p>
- Using --recurse-submodules will update the content of all initialized
- submodules according to the commit recorded in the superproject. If
- local modifications in a submodule would be overwritten the checkout
- will fail unless <code>-f</code> is used. If nothing (or --no-recurse-submodules)
- is used, the work trees of submodules will not be updated.
- Just like <a href="git-submodule.html">git-submodule(1)</a>, this will detach the
- submodules HEAD.
+ Silently overwrite ignored files when switching branches. This
+ is the default behavior. Use <code>--no-overwrite-ignore</code> to abort
+ the operation when the new branch contains ignored files.
</p>
</dd>
<dt class="hdlist1">
---no-guess
+--recurse-submodules
+</dt>
+<dt class="hdlist1">
+--no-recurse-submodules
</dt>
<dd>
<p>
- Do not attempt to create a branch if a remote tracking branch
- of the same name exists.
+ Using <code>--recurse-submodules</code> will update the content of all initialized
+ submodules according to the commit recorded in the superproject. If
+ local modifications in a submodule would be overwritten the checkout
+ will fail unless <code>-f</code> is used. If nothing (or <code>--no-recurse-submodules</code>)
+ is used, the work trees of submodules will not be updated.
+ Just like <a href="git-submodule.html">git-submodule(1)</a>, this will detach <code>HEAD</code> of the
+ submodule.
</p>
</dd>
<dt class="hdlist1">
---[no-]overlay
+--overlay
+</dt>
+<dt class="hdlist1">
+--no-overlay
</dt>
<dd>
<p>
In the default overlay mode, <code>git checkout</code> never
removes files from the index or the working tree. When
specifying <code>--no-overlay</code>, files that appear in the index and
- working tree, but not in &lt;tree-ish&gt; are removed, to make them
- match &lt;tree-ish&gt; exactly.
+ working tree, but not in <code>&lt;tree-ish&gt;</code> are removed, to make them
+ match <code>&lt;tree-ish&gt;</code> exactly.
</p>
</dd>
<dt class="hdlist1">
@@ -1160,13 +1191,13 @@ section of <a href="git-add.html">git-add(1)</a> to learn how to operate the <co
Branch to checkout; if it refers to a branch (i.e., a name that,
when prepended with "refs/heads/", is a valid ref), then that
branch is checked out. Otherwise, if it refers to a valid
- commit, your HEAD becomes "detached" and you are no longer on
+ commit, your <code>HEAD</code> becomes "detached" and you are no longer on
any branch (see below for details).
</p>
-<div class="paragraph"><p>You can use the <code>"@{-N}"</code> syntax to refer to the N-th last
+<div class="paragraph"><p>You can use the <code>@{-N}</code> syntax to refer to the N-th last
branch/commit checked out using "git checkout" operation. You may
-also specify <code>-</code> which is synonymous to <code>"@{-1}"</code>.</p></div>
-<div class="paragraph"><p>As a special case, you may use <code>"A...B"</code> as a shortcut for the
+also specify <code>-</code> which is synonymous to <code>@{-1}</code>.</p></div>
+<div class="paragraph"><p>As a special case, you may use <code>A...B</code> as a shortcut for the
merge base of <code>A</code> and <code>B</code> if there is exactly one merge base. You can
leave out at most one of <code>A</code> and <code>B</code>, in which case it defaults to <code>HEAD</code>.</p></div>
</dd>
@@ -1184,7 +1215,7 @@ leave out at most one of <code>A</code> and <code>B</code>, in which case it def
<dd>
<p>
The name of a commit at which to start the new branch; see
- <a href="git-branch.html">git-branch(1)</a> for details. Defaults to HEAD.
+ <a href="git-branch.html">git-branch(1)</a> for details. Defaults to <code>HEAD</code>.
</p>
<div class="paragraph"><p>As a special case, you may use <code>"A...B"</code> as a shortcut for the
merge base of <code>A</code> and <code>B</code> if there is exactly one merge base. You can
@@ -1205,9 +1236,9 @@ leave out at most one of <code>A</code> and <code>B</code>, in which case it def
<div class="sect1">
<h2 id="_detached_head">DETACHED HEAD</h2>
<div class="sectionbody">
-<div class="paragraph"><p>HEAD normally refers to a named branch (e.g. <em>master</em>). Meanwhile, each
+<div class="paragraph"><p><code>HEAD</code> normally refers to a named branch (e.g. <code>master</code>). Meanwhile, each
branch refers to a specific commit. Let&#8217;s look at a repo with three
-commits, one of them tagged, and with branch <em>master</em> checked out:</p></div>
+commits, one of them tagged, and with branch <code>master</code> checked out:</p></div>
<div class="listingblock">
<div class="content">
<pre><code> HEAD (refers to branch 'master')
@@ -1219,10 +1250,10 @@ a---b---c branch 'master' (refers to commit 'c')
tag 'v2.0' (refers to commit 'b')</code></pre>
</div></div>
<div class="paragraph"><p>When a commit is created in this state, the branch is updated to refer to
-the new commit. Specifically, <em>git commit</em> creates a new commit <em>d</em>, whose
-parent is commit <em>c</em>, and then updates branch <em>master</em> to refer to new
-commit <em>d</em>. HEAD still refers to branch <em>master</em> and so indirectly now refers
-to commit <em>d</em>:</p></div>
+the new commit. Specifically, <em>git commit</em> creates a new commit <code>d</code>, whose
+parent is commit <code>c</code>, and then updates branch <code>master</code> to refer to new
+commit <code>d</code>. <code>HEAD</code> still refers to branch <code>master</code> and so indirectly now refers
+to commit <code>d</code>:</p></div>
<div class="listingblock">
<div class="content">
<pre><code>$ edit; git add; git commit
@@ -1238,7 +1269,7 @@ a---b---c---d branch 'master' (refers to commit 'd')
<div class="paragraph"><p>It is sometimes useful to be able to checkout a commit that is not at
the tip of any named branch, or even to create a new commit that is not
referenced by a named branch. Let&#8217;s look at what happens when we
-checkout commit <em>b</em> (here we show two ways this may be done):</p></div>
+checkout commit <code>b</code> (here we show two ways this may be done):</p></div>
<div class="listingblock">
<div class="content">
<pre><code>$ git checkout v2.0 # or
@@ -1252,9 +1283,9 @@ a---b---c---d branch 'master' (refers to commit 'd')
|
tag 'v2.0' (refers to commit 'b')</code></pre>
</div></div>
-<div class="paragraph"><p>Notice that regardless of which checkout command we use, HEAD now refers
-directly to commit <em>b</em>. This is known as being in detached HEAD state.
-It means simply that HEAD refers to a specific commit, as opposed to
+<div class="paragraph"><p>Notice that regardless of which checkout command we use, <code>HEAD</code> now refers
+directly to commit <code>b</code>. This is known as being in detached <code>HEAD</code> state.
+It means simply that <code>HEAD</code> refers to a specific commit, as opposed to
referring to a named branch. Let&#8217;s see what happens when we create a commit:</p></div>
<div class="listingblock">
<div class="content">
@@ -1270,7 +1301,7 @@ a---b---c---d branch 'master' (refers to commit 'd')
|
tag 'v2.0' (refers to commit 'b')</code></pre>
</div></div>
-<div class="paragraph"><p>There is now a new commit <em>e</em>, but it is referenced only by HEAD. We can
+<div class="paragraph"><p>There is now a new commit <code>e</code>, but it is referenced only by <code>HEAD</code>. We can
of course add yet another commit in this state:</p></div>
<div class="listingblock">
<div class="content">
@@ -1287,7 +1318,7 @@ a---b---c---d branch 'master' (refers to commit 'd')
tag 'v2.0' (refers to commit 'b')</code></pre>
</div></div>
<div class="paragraph"><p>In fact, we can perform all the normal Git operations. But, let&#8217;s look
-at what happens when we then checkout master:</p></div>
+at what happens when we then checkout <code>master</code>:</p></div>
<div class="listingblock">
<div class="content">
<pre><code>$ git checkout master
@@ -1301,9 +1332,9 @@ a---b---c---d branch 'master' (refers to commit 'd')
tag 'v2.0' (refers to commit 'b')</code></pre>
</div></div>
<div class="paragraph"><p>It is important to realize that at this point nothing refers to commit
-<em>f</em>. Eventually commit <em>f</em> (and by extension commit <em>e</em>) will be deleted
+<code>f</code>. Eventually commit <code>f</code> (and by extension commit <code>e</code>) will be deleted
by the routine Git garbage collection process, unless we create a reference
-before that happens. If we have not yet moved away from commit <em>f</em>,
+before that happens. If we have not yet moved away from commit <code>f</code>,
any of these will create a reference to it:</p></div>
<div class="listingblock">
<div class="content">
@@ -1314,27 +1345,27 @@ $ git tag foo <b>&lt;3&gt;</b></code></pre>
<div class="colist arabic"><ol>
<li>
<p>
-creates a new branch <em>foo</em>, which refers to commit <em>f</em>, and then
- updates HEAD to refer to branch <em>foo</em>. In other words, we&#8217;ll no longer
- be in detached HEAD state after this command.
+creates a new branch <code>foo</code>, which refers to commit <code>f</code>, and then
+ updates <code>HEAD</code> to refer to branch <code>foo</code>. In other words, we&#8217;ll no longer
+ be in detached <code>HEAD</code> state after this command.
</p>
</li>
<li>
<p>
-similarly creates a new branch <em>foo</em>, which refers to commit <em>f</em>,
- but leaves HEAD detached.
+similarly creates a new branch <code>foo</code>, which refers to commit <code>f</code>,
+ but leaves <code>HEAD</code> detached.
</p>
</li>
<li>
<p>
-creates a new tag <em>foo</em>, which refers to commit <em>f</em>,
- leaving HEAD detached.
+creates a new tag <code>foo</code>, which refers to commit <code>f</code>,
+ leaving <code>HEAD</code> detached.
</p>
</li>
</ol></div>
-<div class="paragraph"><p>If we have moved away from commit <em>f</em>, then we must first recover its object
+<div class="paragraph"><p>If we have moved away from commit <code>f</code>, then we must first recover its object
name (typically by using git reflog), and then we can create a reference to
-it. For example, to see the last two commits to which HEAD referred, we
+it. For example, to see the last two commits to which <code>HEAD</code> referred, we
can use either of these commands:</p></div>
<div class="listingblock">
<div class="content">
@@ -1346,12 +1377,12 @@ $ git log -g -2 HEAD</code></pre>
<div class="sect1">
<h2 id="_argument_disambiguation">ARGUMENT DISAMBIGUATION</h2>
<div class="sectionbody">
-<div class="paragraph"><p>When there is only one argument given and it is not <code>--</code> (e.g. "git
-checkout abc"), and when the argument is both a valid <code>&lt;tree-ish&gt;</code>
-(e.g. a branch "abc" exists) and a valid <code>&lt;pathspec&gt;</code> (e.g. a file
+<div class="paragraph"><p>When there is only one argument given and it is not <code>--</code> (e.g. <code>git
+checkout abc</code>), and when the argument is both a valid <code>&lt;tree-ish&gt;</code>
+(e.g. a branch <code>abc</code> exists) and a valid <code>&lt;pathspec&gt;</code> (e.g. a file
or a directory whose name is "abc" exists), Git would usually ask
you to disambiguate. Because checking out a branch is so common an
-operation, however, "git checkout abc" takes "abc" as a <code>&lt;tree-ish&gt;</code>
+operation, however, <code>git checkout abc</code> takes "abc" as a <code>&lt;tree-ish&gt;</code>
in such a situation. Use <code>git checkout -- &lt;pathspec&gt;</code> if you want
to checkout these paths out of the index.</p></div>
</div>
@@ -1363,7 +1394,7 @@ to checkout these paths out of the index.</p></div>
<li>
<p>
The following sequence checks out the <code>master</code> branch, reverts
- the <code>Makefile</code> to two revisions back, deletes hello.c by
+ the <code>Makefile</code> to two revisions back, deletes <code>hello.c</code> by
mistake, and gets it back from the index.
</p>
<div class="listingblock">
@@ -1386,7 +1417,7 @@ take a file out of another commit
</li>
<li>
<p>
-restore hello.c from the index
+restore <code>hello.c</code> from the index
</p>
<div class="paragraph"><p>If you want to check out <em>all</em> C source files out of the index,
you can say</p></div>
@@ -1417,7 +1448,7 @@ After working in the wrong branch, switching to the correct
<div class="content">
<pre><code>$ git checkout mytopic</code></pre>
</div></div>
-<div class="paragraph"><p>However, your "wrong" branch and correct "mytopic" branch may
+<div class="paragraph"><p>However, your "wrong" branch and correct <code>mytopic</code> branch may
differ in files that you have modified locally, in which case
the above checkout would fail like this:</p></div>
<div class="listingblock">
@@ -1462,6 +1493,13 @@ $ git add frotz</code></pre>
</div>
</div>
<div class="sect1">
+<h2 id="_see_also">SEE ALSO</h2>
+<div class="sectionbody">
+<div class="paragraph"><p><a href="git-switch.html">git-switch(1)</a>,
+<a href="git-restore.html">git-restore(1)</a></p></div>
+</div>
+</div>
+<div class="sect1">
<h2 id="_git">GIT</h2>
<div class="sectionbody">
<div class="paragraph"><p>Part of the <a href="git.html">git(1)</a> suite</p></div>
@@ -1472,7 +1510,7 @@ $ git add frotz</code></pre>
<div id="footer">
<div id="footer-text">
Last updated
- 2019-05-19 01:58:26 PDT
+ 2019-07-09 19:51:04 PDT
</div>
</div>
</body>