threads / patch / 18755

patch, 2 partsgit-checkout.txt: clarify that <branch> applies when no path is given.

Subject: [PATCH 2/2] git-checkout.txt: clarify that <branch> applies when no path is given.

## tl;dr

6 messages between Apr 6, 2009 and Apr 7, 2009. Diffs are folded; open one to read it.

replies: 5people: 3as markdown or json

Matthieu Moy· Apr 6, 2009, 20:45 UTC · lore

[PATCH 1/2] git-checkout.txt: fix incorrect statement about HEAD and index

The command "git checkout" checks out from the index by default, not HEAD (the introducing comment were correct, but the detailled explanation added below were not).

Signed-off-by: Matthieu Moy <Matthieu.Moy@imag.fr>
---
 Documentation/git-checkout.txt |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
Show changes to Documentation/git-checkout.txt +1 −1
diff --git a/Documentation/git-checkout.txt b/Documentation/git-checkout.txt
index 1a6c19e..0b5485b 100644
--- a/Documentation/git-checkout.txt
+++ b/Documentation/git-checkout.txt
@@ -191,7 +191,7 @@ $ git checkout hello.c            <3>
 +
 <1> switch branch
 <2> take a file out of another commit
-<3> restore hello.c from HEAD of current branch
+<3> restore hello.c from the index
 +
 If you have an unfortunate branch that is named `hello.c`, this
 step would be confused as an instruction to switch to that branch.
-- 
1.6.2.1.427.g061ea
Matthieu Moy· Apr 6, 2009, 20:45 UTC · re: Matthieu Moy · lore

Otherwise, the sentence "Defaults to HEAD." can be mis-read to mean that "git checkout -- hello.c" checks-out from HEAD.

Signed-off-by: Matthieu Moy <Matthieu.Moy@imag.fr>
---

This may be a bit too verbose, but I've been biten by this (reading the doc not carrefully enough, I really thought git checkout would take HEAD, then I thought it was actually a documentation bug, and then I realized I miss-read). This patch would have saved me time. But if other disagree, I won't fight ;-).

 Documentation/git-checkout.txt |    9 +++++++--
 1 files changed, 7 insertions(+), 2 deletions(-)
Show changes to Documentation/git-checkout.txt +7 −2
diff --git a/Documentation/git-checkout.txt b/Documentation/git-checkout.txt
index 0b5485b..58bf508 100644
--- a/Documentation/git-checkout.txt
+++ b/Documentation/git-checkout.txt
@@ -126,9 +126,14 @@ the conflicted merge in the specified paths.
 <new_branch>::
 	Name for the new branch.
 
+<tree-ish>::
+	Tree to checkout from (when path are given). If not specified,
+	the index will be used.
+
 <branch>::
-	Branch to checkout; may be any object ID that resolves to a
-	commit.  Defaults to HEAD.
+	Branch to checkout (when no path are given); may be any object
+	ID that resolves to a commit.  Defaults to HEAD.
+
 +
 When this parameter names a non-branch (but still a valid commit object),
 your HEAD becomes 'detached'.
-- 
1.6.2.1.427.g061ea
Mike Ralphson· Apr 7, 2009, 09:41 UTC · re: Matthieu Moy · lore

Re: [PATCH 2/2] git-checkout.txt: clarify that <branch> applies when no path is given.

2009/4/6 Matthieu Moy <Matthieu.Moy@imag.fr>:
> Otherwise, the sentence "Defaults to HEAD." can be mis-read to mean
> that "git checkout -- hello.c" checks-out from HEAD.
Show 18 quoted lines
> diff --git a/Documentation/git-checkout.txt b/Documentation/git-checkout.txt
> index 0b5485b..58bf508 100644
> --- a/Documentation/git-checkout.txt
> +++ b/Documentation/git-checkout.txt
> @@ -126,9 +126,14 @@ the conflicted merge in the specified paths.
>  <new_branch>::
>        Name for the new branch.
>
> +<tree-ish>::
> +       Tree to checkout from (when path are given). If not specified,
> +       the index will be used.
> +
>  <branch>::
> -       Branch to checkout; may be any object ID that resolves to a
> -       commit.  Defaults to HEAD.
> +       Branch to checkout (when no path are given); may be any object
> +       ID that resolves to a commit.  Defaults to HEAD.
> +
s/path are/paths are/g

Sorry if I come across as picking on your grammar, I think your documentation improvements are very worthwhile.

Mike
Matthieu Moy· Apr 7, 2009, 10:20 UTC · re: Mike Ralphson · lore

[PATCH 1/2] git-checkout.txt: clarify that <branch> applies when no path is given.

Otherwise, the sentence "Defaults to HEAD." can be mis-read to mean that "git checkout -- hello.c" checks-out from HEAD.

Signed-off-by: Matthieu Moy <Matthieu.Moy@imag.fr>
---
> s/path are/paths are/g
Right.

I'm not 100% sure about "no paths are given" Vs "no path is given", but my understanding of english grammar is that since there could have been several paths, the absence of path is still plural (French would be singular here).

> Sorry if I come across as picking on your grammar, I think your
> documentation improvements are very worthwhile.
No harm ;-).
 Documentation/git-checkout.txt |    9 +++++++--
 1 files changed, 7 insertions(+), 2 deletions(-)
Show changes to Documentation/git-checkout.txt +7 −2
diff --git a/Documentation/git-checkout.txt b/Documentation/git-checkout.txt
index 0b5485b..7eafcdf 100644
--- a/Documentation/git-checkout.txt
+++ b/Documentation/git-checkout.txt
@@ -126,9 +126,14 @@ the conflicted merge in the specified paths.
 <new_branch>::
 	Name for the new branch.
 
+<tree-ish>::
+	Tree to checkout from (when paths are given). If not specified,
+	the index will be used.
+
 <branch>::
-	Branch to checkout; may be any object ID that resolves to a
-	commit.  Defaults to HEAD.
+	Branch to checkout (when no paths are given); may be any object
+	ID that resolves to a commit.  Defaults to HEAD.
+
 +
 When this parameter names a non-branch (but still a valid commit object),
 your HEAD becomes 'detached'.
-- 
1.6.2.2.449.g92961.dirty
Matthieu Moy· Apr 7, 2009, 12:43 UTC · re: Matthieu Moy · lore

[PATCH v2] git-checkout.txt: clarify that <branch> applies when no path is given.

Otherwise, the sentence "Defaults to HEAD." can be mis-read to mean that "git checkout -- hello.c" checks-out from HEAD.

Signed-off-by: Matthieu Moy <Matthieu.Moy@imag.fr>
---
Sorry, patch v1 was introducing a spurious newline, which broke
asciidoc syntax. This fixes it, but Junio, if you already applied v1,
just remove the empty line after <branch>:: and before +.
 Documentation/git-checkout.txt |    8 ++++++--
 1 files changed, 6 insertions(+), 2 deletions(-)
Show changes to Documentation/git-checkout.txt +6 −2
diff --git a/Documentation/git-checkout.txt b/Documentation/git-checkout.txt
index 0b5485b..223ea9c 100644
--- a/Documentation/git-checkout.txt
+++ b/Documentation/git-checkout.txt
@@ -126,9 +126,13 @@ the conflicted merge in the specified paths.
 <new_branch>::
 	Name for the new branch.
 
+<tree-ish>::
+	Tree to checkout from (when paths are given). If not specified,
+	the index will be used.
+
 <branch>::
-	Branch to checkout; may be any object ID that resolves to a
-	commit.  Defaults to HEAD.
+	Branch to checkout (when no paths are given); may be any object
+	ID that resolves to a commit.  Defaults to HEAD.
 +
 When this parameter names a non-branch (but still a valid commit object),
 your HEAD becomes 'detached'.
-- 
1.6.2.2.449.g92961.dirty

← back to recent threads