threads / patch / 25089

patch, 6 partsgit-reset.txt: point to git-checkout

Subject: [PATCH 5/6] git-reset.txt: point to git-checkout

## tl;dr

22 messages between Sep 13, 2010 and Sep 15, 2010. Diffs are folded; open one to read it.

replies: 21people: 3as markdown or json

Michael J Gruber· Sep 13, 2010, 08:06 UTC · lore

[PATCH 0/6] git-reset.txt improvements

First of all: I've been out of the loop last week, so please forgive me if this comes at the wrong phase of a cycle.

I portioned the changes to git-reset.txt and ordered them starting from the least controversial, I hope. The descriptions of modes have grown organically over time, and this series tries to make them consistent in structure and wording, after cleaning up some minor issues. 6/6 is the "meat", so to say.

For the "--merge" description in 6/6: Please double check. I've tried to understand the mode from the tables and from the inner works (git read-tre -u -m plus carrying over unmerged entries) because I did not understand the original description.

Michael J Gruber (6):
  git-reset.txt: clarify branch vs. branch head
  git-reset.txt: reset does not change files in target
  git-reset.txt: reset --soft is not a no-op
  git-reset.txt: use "working tree" consistently
  git-reset.txt: point to git-checkout
  git-reset.txt: make modes description more consistent
 Documentation/git-reset.txt |   63 ++++++++++++++++++++++++++-----------------
 1 files changed, 38 insertions(+), 25 deletions(-)
-- 
1.7.3.rc1.215.g6997c
Michael J Gruber· Sep 13, 2010, 08:06 UTC · re: Michael J Gruber · lore

[PATCH 1/6] git-reset.txt: clarify branch vs. branch head

"Change the branch" can be misunderstood to mean "change which branch is checked out". Make it clearer that git-reset changes the branch head of the currently checked out branch.

Signed-off-by: Michael J Gruber <git@drmicha.warpmail.net>
---
 Documentation/git-reset.txt |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)
Show changes to Documentation/git-reset.txt +2 −2
diff --git a/Documentation/git-reset.txt b/Documentation/git-reset.txt
index 9cf3148..7d68b4c 100644
--- a/Documentation/git-reset.txt
+++ b/Documentation/git-reset.txt
@@ -15,7 +15,7 @@ SYNOPSIS
 DESCRIPTION
 -----------
 In the first and second form, copy entries from <commit> to the index.
-In the third form, set the current branch to <commit>, optionally
+In the third form, set the current branch head to <commit>, optionally
 modifying index and worktree to match.  The <commit> defaults to HEAD
 in all forms.
 
@@ -36,7 +36,7 @@ This means that `git reset -p` is the opposite of `git add -p` (see
 linkgit:git-add[1]).
 
 'git reset' [--<mode>] [<commit>]::
-	This form points the current branch to <commit> and then
+	This form sets the current branch head to <commit> and then
 	updates index and working tree according to <mode>, which must
 	be one of the following:
 +
-- 
1.7.3.rc1.215.g6997c
Junio C Hamano· Sep 14, 2010, 00:35 UTC · re: Michael J Gruber · lore

Re: [PATCH 1/6] git-reset.txt: clarify branch vs. branch head

Michael J Gruber <git@drmicha.warpmail.net> writes:
Show 8 quoted lines
> @@ -36,7 +36,7 @@ This means that `git reset -p` is the opposite of `git add -p` (see
>  linkgit:git-add[1]).
>  
>  'git reset' [--<mode>] [<commit>]::
> -	This form points the current branch to <commit> and then
> +	This form sets the current branch head to <commit> and then
>  	updates index and working tree according to <mode>, which must
>  	be one of the following:
Perhaps "resets" or "moves" is even clearer?
In any case I think this is an improvement.
Michael J Gruber· Sep 13, 2010, 08:06 UTC · re: Michael J Gruber · lore

[PATCH 2/6] git-reset.txt: reset does not change files in target

git-reset obviously cannot change files in an existing commit. Make it not sound as if it could: reset can change HEAD and, in that sense, can change which state a file in HEAD is in.

Signed-off-by: Michael J Gruber <git@drmicha.warpmail.net>
---
 Documentation/git-reset.txt |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
Show changes to Documentation/git-reset.txt +1 −1
diff --git a/Documentation/git-reset.txt b/Documentation/git-reset.txt
index 7d68b4c..8fb871c 100644
--- a/Documentation/git-reset.txt
+++ b/Documentation/git-reset.txt
@@ -295,7 +295,7 @@ file. For example, the first line of the first table means that if a
 file is in state A in the working tree, in state B in the index, in
 state C in HEAD and in state D in the target, then "git reset --soft
 target" will put the file in state A in the working tree, in state B
-in the index and in state D in HEAD.
+in the index and set HEAD to target (which has the file in state D).
 
       working index HEAD target         working index HEAD
       ----------------------------------------------------
-- 
1.7.3.rc1.215.g6997c
Junio C Hamano· Sep 14, 2010, 00:12 UTC · re: Michael J Gruber · lore

Re: [PATCH 2/6] git-reset.txt: reset does not change files in target

Michael J Gruber <git@drmicha.warpmail.net> writes:
Show 14 quoted lines
> git-reset obviously cannot change files in an existing commit. Make it
> not sound as if it could: reset can change HEAD and, in that sense, can
> change which state a file in HEAD is in.
> ...
> diff --git a/Documentation/git-reset.txt b/Documentation/git-reset.txt
> index 7d68b4c..8fb871c 100644
> --- a/Documentation/git-reset.txt
> +++ b/Documentation/git-reset.txt
> @@ -295,7 +295,7 @@ file. For example, the first line of the first table means that if a
>  file is in state A in the working tree, in state B in the index, in
>  state C in HEAD and in state D in the target, then "git reset --soft
>  target" will put the file in state A in the working tree, in state B
> -in the index and in state D in HEAD.
> +in the index and set HEAD to target (which has the file in state D).

I would further suggest to make it clear that soft reset does not touch either the index nor the working tree, e.g.:

    "git reset --soft target" will leave the file in the working tree in
    state A and the index in state B.  It moves the HEAD (i.e. the tip of
    the current branch, if you are on one) to "target" (which has the file
    in state D).
Michael J Gruber· Sep 13, 2010, 08:06 UTC · re: Michael J Gruber · lore

[PATCH 3/6] git-reset.txt: reset --soft is not a no-op

Make it clearer that git reset --soft actually does something (changing HEAD). While it is meantioned in the previous paragraph already it can be easily overlooked otherwise.

Signed-off-by: Michael J Gruber <git@drmicha.warpmail.net>
---
 Documentation/git-reset.txt |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)
Show changes to Documentation/git-reset.txt +2 −1
diff --git a/Documentation/git-reset.txt b/Documentation/git-reset.txt
index 8fb871c..65f5d07 100644
--- a/Documentation/git-reset.txt
+++ b/Documentation/git-reset.txt
@@ -43,7 +43,8 @@ linkgit:git-add[1]).
 --
 --soft::
 	Does not touch the index file nor the working tree at all, but
-	requires them to be in a good order. This leaves all your changed
+	requires them to be in good order (and sets the head to <commit>,
+	just like all modes do). This leaves all your changed
 	files "Changes to be committed", as 'git status' would
 	put it.
 
-- 
1.7.3.rc1.215.g6997c
Jay Soffian· Sep 13, 2010, 22:13 UTC · re: Michael J Gruber · lore

Re: [PATCH 3/6] git-reset.txt: reset --soft is not a no-op

On Mon, Sep 13, 2010 at 4:06 AM, Michael J Gruber <git@drmicha.warpmail.net> wrote:

Show 22 quoted lines
> Make it clearer that git reset --soft actually does something (changing
> HEAD). While it is meantioned in the previous paragraph already it can
> be easily overlooked otherwise.
>
> Signed-off-by: Michael J Gruber <git@drmicha.warpmail.net>
> ---
>  Documentation/git-reset.txt |    3 ++-
>  1 files changed, 2 insertions(+), 1 deletions(-)
>
> diff --git a/Documentation/git-reset.txt b/Documentation/git-reset.txt
> index 8fb871c..65f5d07 100644
> --- a/Documentation/git-reset.txt
> +++ b/Documentation/git-reset.txt
> @@ -43,7 +43,8 @@ linkgit:git-add[1]).
>  --
>  --soft::
>        Does not touch the index file nor the working tree at all, but
> -       requires them to be in a good order. This leaves all your changed
> +       requires them to be in good order (and sets the head to <commit>,
> +       just like all modes do). This leaves all your changed
>        files "Changes to be committed", as 'git status' would
>        put it.
What does "requires them to be in good order" mean anyway?
j.
Junio C Hamano· Sep 13, 2010, 23:19 UTC · re: Jay Soffian · lore

Re: [PATCH 3/6] git-reset.txt: reset --soft is not a no-op

Jay Soffian <jaysoffian@gmail.com> writes:
Show 26 quoted lines
> On Mon, Sep 13, 2010 at 4:06 AM, Michael J Gruber
> <git@drmicha.warpmail.net> wrote:
>> Make it clearer that git reset --soft actually does something (changing
>> HEAD). While it is meantioned in the previous paragraph already it can
>> be easily overlooked otherwise.
>>
>> Signed-off-by: Michael J Gruber <git@drmicha.warpmail.net>
>> ---
>>  Documentation/git-reset.txt |    3 ++-
>>  1 files changed, 2 insertions(+), 1 deletions(-)
>>
>> diff --git a/Documentation/git-reset.txt b/Documentation/git-reset.txt
>> index 8fb871c..65f5d07 100644
>> --- a/Documentation/git-reset.txt
>> +++ b/Documentation/git-reset.txt
>> @@ -43,7 +43,8 @@ linkgit:git-add[1]).
>>  --
>>  --soft::
>>        Does not touch the index file nor the working tree at all, but
>> -       requires them to be in a good order. This leaves all your changed
>> +       requires them to be in good order (and sets the head to <commit>,
>> +       just like all modes do). This leaves all your changed
>>        files "Changes to be committed", as 'git status' would
>>        put it.
>
> What does "requires them to be in good order" mean anyway?

Good point. I don't think it means anything now; for that matter I do not think it meant anything even back when that sentence was added in f67545e (Docs for git-reset-script., 2005-09-07). A soft reset doesn't even look at the index nor the working tree, so there is no good nor bad order there.

Just remove it.
Michael J Gruber· Sep 13, 2010, 08:06 UTC · re: Michael J Gruber · lore

[PATCH 4/6] git-reset.txt: use "working tree" consistently

as per git help glossary
Signed-off-by: Michael J Gruber <git@drmicha.warpmail.net>
---
 Documentation/git-reset.txt |   14 +++++++-------
 1 files changed, 7 insertions(+), 7 deletions(-)
Show changes to Documentation/git-reset.txt +7 −7
diff --git a/Documentation/git-reset.txt b/Documentation/git-reset.txt
index 65f5d07..60b4b80 100644
--- a/Documentation/git-reset.txt
+++ b/Documentation/git-reset.txt
@@ -16,12 +16,12 @@ DESCRIPTION
 -----------
 In the first and second form, copy entries from <commit> to the index.
 In the third form, set the current branch head to <commit>, optionally
-modifying index and worktree to match.  The <commit> defaults to HEAD
+modifying index and working tree to match.  The <commit> defaults to HEAD
 in all forms.
 
 'git reset' [-q] [<commit>] [--] <paths>...::
 	This form resets the index entries for all <paths> to their
-	state at the <commit>.  (It does not affect the worktree, nor
+	state at the <commit>.  (It does not affect the working tree, nor
 	the current branch.)
 +
 This means that `git reset <paths>` is the opposite of `git add
@@ -185,7 +185,7 @@ tip of the current branch in ORIG_HEAD, so resetting hard to it
 brings your index file and the working tree back to that state,
 and resets the tip of the branch to that commit.
 
-Undo a merge or pull inside a dirty work tree::
+Undo a merge or pull inside a dirty working tree::
 +
 ------------
 $ git pull                         <1>
@@ -258,7 +258,7 @@ Suppose you are working on something and you commit it, and then you
 continue working a bit more, but now you think that what you have in
 your working tree should be in another branch that has nothing to do
 with what you committed previously. You can start a new branch and
-reset it while keeping the changes in your work tree.
+reset it while keeping the changes in your working tree.
 +
 ------------
 $ git tag start
@@ -347,11 +347,11 @@ in the index and set HEAD to target (which has the file in state D).
 				--keep   B       C     C
 
 "reset --merge" is meant to be used when resetting out of a conflicted
-merge. Any mergy operation guarantees that the work tree file that is
+merge. Any mergy operation guarantees that the working tree file that is
 involved in the merge does not have local change wrt the index before
-it starts, and that it writes the result out to the work tree. So if
+it starts, and that it writes the result out to the working tree. So if
 we see some difference between the index and the target and also
-between the index and the work tree, then it means that we are not
+between the index and the working tree, then it means that we are not
 resetting out from a state that a mergy operation left after failing
 with a conflict. That is why we disallow --merge option in this case.
 
-- 
1.7.3.rc1.215.g6997c
Michael J Gruber· Sep 13, 2010, 08:06 UTC · re: Michael J Gruber · lore
for the case of updating a file in index and worktree.
Signed-off-by: Michael J Gruber <git@drmicha.warpmail.net>
---
 Documentation/git-reset.txt |    3 +++
 1 files changed, 3 insertions(+), 0 deletions(-)
Show changes to Documentation/git-reset.txt +3 −0
diff --git a/Documentation/git-reset.txt b/Documentation/git-reset.txt
index 60b4b80..40e2fd8 100644
--- a/Documentation/git-reset.txt
+++ b/Documentation/git-reset.txt
@@ -27,6 +27,9 @@ in all forms.
 This means that `git reset <paths>` is the opposite of `git add
 <paths>`.
 
+If you want to reset index entry and working tree state of a file,
+linkgit:git-checkout[1] is your friend.
+
 'git reset' --patch|-p [<commit>] [--] [<paths>...]::
 	Interactively select hunks in the difference between the index
 	and <commit> (defaults to HEAD).  The chosen hunks are applied
-- 
1.7.3.rc1.215.g6997c
Junio C Hamano· Sep 14, 2010, 00:19 UTC · re: Michael J Gruber · lore

Re: [PATCH 5/6] git-reset.txt: point to git-checkout

Michael J Gruber <git@drmicha.warpmail.net> writes:
Show 18 quoted lines
> for the case of updating a file in index and worktree.
>
> Signed-off-by: Michael J Gruber <git@drmicha.warpmail.net>
> ---
>  Documentation/git-reset.txt |    3 +++
>  1 files changed, 3 insertions(+), 0 deletions(-)
>
> diff --git a/Documentation/git-reset.txt b/Documentation/git-reset.txt
> index 60b4b80..40e2fd8 100644
> --- a/Documentation/git-reset.txt
> +++ b/Documentation/git-reset.txt
> @@ -27,6 +27,9 @@ in all forms.
>  This means that `git reset <paths>` is the opposite of `git add
>  <paths>`.
>  
> +If you want to reset index entry and working tree state of a file,
> +linkgit:git-checkout[1] is your friend.
> +
I am not quite sure if this is an improvement.

You can reset the index entry using git-reset and then check the path out of the index to the working tree using git-checkout, in two separate steps. You can alternatively stuff the contents out of a commit (or more in general any tree-ish) to the index and check it out to the working tree with a single git-checkout. It is obvious to _me_ that you meant to hint the latter in the above, but for people who need that hint it probably isn't. Can we make it clearer? Perhaps...

    Using linkgit:git-checkout[1], you can copy the contents of a path out
    of a commit to the index and to the working tree in one go.
Or if you meant the former, 
    After running "git reset <paths>" to update the index entry, you can
    use linkgit:git-checkout[1] to check the contents out of the index to
    the working tree.
Michael J Gruber· Sep 13, 2010, 08:06 UTC · re: Michael J Gruber · lore

[PATCH 6/6] git-reset.txt: make modes description more consistent

Currently, the structure of the individual mode entries is different which makes it difficult to grasp the differences between the modes. Also, the same items are named differently (e.g. <commit>, "the named commit", "the given commit", "the commit being switched to").

Structure and word all mode entries consistently.
Signed-off-by: Michael J Gruber <git@drmicha.warpmail.net>
---
 Documentation/git-reset.txt |   43 ++++++++++++++++++++++++++-----------------
 1 files changed, 26 insertions(+), 17 deletions(-)
Show changes to Documentation/git-reset.txt +26 −17
diff --git a/Documentation/git-reset.txt b/Documentation/git-reset.txt
index 40e2fd8..6b60b59 100644
--- a/Documentation/git-reset.txt
+++ b/Documentation/git-reset.txt
@@ -15,13 +15,13 @@ SYNOPSIS
 DESCRIPTION
 -----------
 In the first and second form, copy entries from <commit> to the index.
-In the third form, set the current branch head to <commit>, optionally
+In the third form, set the current branch head (HEAD) to <commit>, optionally
 modifying index and working tree to match.  The <commit> defaults to HEAD
 in all forms.
 
 'git reset' [-q] [<commit>] [--] <paths>...::
 	This form resets the index entries for all <paths> to their
-	state at the <commit>.  (It does not affect the working tree, nor
+	state at <commit>.  (It does not affect the working tree, nor
 	the current branch.)
 +
 This means that `git reset <paths>` is the opposite of `git add
@@ -39,9 +39,10 @@ This means that `git reset -p` is the opposite of `git add -p` (see
 linkgit:git-add[1]).
 
 'git reset' [--<mode>] [<commit>]::
-	This form sets the current branch head to <commit> and then
-	updates index and working tree according to <mode>, which must
-	be one of the following:
+	This form sets the current branch head to <commit> and
+	possibly updates the index (resetting it to the tree of <commit>) and
+	the working tree depending on <mode>, which
+	must be one of the following:
 +
 --
 --soft::
@@ -57,22 +58,30 @@ linkgit:git-add[1]).
 	been updated. This is the default action.
 
 --hard::
-	Matches the working tree and index to that of the tree being
-	switched to. Any changes to tracked files in the working tree
-	since <commit> are lost.
+	Resets the index and working tree. Any changes to tracked files in the
+	working tree since <commit> are lost.
 
 --merge::
-	Resets the index to match the tree recorded by the named commit,
-	and updates the files that are different between the named commit
-	and the current commit in the working tree.
+	Resets the index and updates the files in the working tree that are
+	different between <commit> and HEAD, but keeps those which are
+	different between the index and working tree (i.e. which have unstaged
+	changes).
+	If a file that is different between <commit> and the index has unstaged
+	changes, reset is aborted.
++
+In other words, --merge does something like a 'git read-tree -u -m <commit>',
+but carries forward unmerged index entries.
 
 --keep::
-	Reset the index to the given commit, keeping local changes in
-	the working tree since the current commit, while updating
-	working tree files without local changes to what appears in
-	the given commit.  If a file that is different between the
-	current commit and the given commit has local changes, reset
-	is aborted.
+	Resets the index, updates files in the working tree that are
+	different between <commit> and HEAD, but keeps those
+	which are different between HEAD and the working tree (i.e.
+	which have local changes).
+	If a file that is different between <commit> and HEAD has local changes,
+	reset is aborted.
++
+In other words, --keep does a 2-way merge between <commit> and HEAD followed by
+'git reset --mixed <commit>'.
 --
 
 If you want to undo a commit other than the latest on a branch,
-- 
1.7.3.rc1.215.g6997c
Junio C Hamano· Sep 14, 2010, 00:35 UTC · re: Michael J Gruber · lore

Re: [PATCH 6/6] git-reset.txt: make modes description more consistent

Michael J Gruber <git@drmicha.warpmail.net> writes:
Show 12 quoted lines
> diff --git a/Documentation/git-reset.txt b/Documentation/git-reset.txt
> index 40e2fd8..6b60b59 100644
> --- a/Documentation/git-reset.txt
> +++ b/Documentation/git-reset.txt
> @@ -15,13 +15,13 @@ SYNOPSIS
>  DESCRIPTION
>  -----------
>  In the first and second form, copy entries from <commit> to the index.
> -In the third form, set the current branch head to <commit>, optionally
> +In the third form, set the current branch head (HEAD) to <commit>, optionally
>  modifying index and working tree to match.  The <commit> defaults to HEAD
>  in all forms.

In the documentation (not limited to "git reset"), we say "update HEAD" and expect the reader to understand that (1) when HEAD is not detached, that updates what commit the current branch points at, (2) when HEAD is detached, no branch is affected.

But that is asking too much to newcomers who weren't around before we introduced detached HEAD around 1.5.0 timeframe. This documentation glitch is there primarily because the detached HEAD came much later than all the "updates the branch" concepts were codified and documented for many commands that advance/modify history, e.g. reset, commit, merge, etc.

We should rectify this, and I think this series is going in the right direction.

Show 11 quoted lines
> @@ -39,9 +39,10 @@ This means that `git reset -p` is the opposite of `git add -p` (see
>  linkgit:git-add[1]).
>  
>  'git reset' [--<mode>] [<commit>]::
> -	This form sets the current branch head to <commit> and then
> -	updates index and working tree according to <mode>, which must
> -	be one of the following:
> +	This form sets the current branch head to <commit> and
> +	possibly updates the index (resetting it to the tree of <commit>) and
> +	the working tree depending on <mode>, which
> +	must be one of the following:
Nice.
Show 9 quoted lines
> @@ -57,22 +58,30 @@ linkgit:git-add[1]).
>  	been updated. This is the default action.
>  
>  --hard::
> -	Matches the working tree and index to that of the tree being
> -	switched to. Any changes to tracked files in the working tree
> -	since <commit> are lost.
> +	Resets the index and working tree. Any changes to tracked files in the
> +	working tree since <commit> are lost.

Explaining what "reset" does using the undefined word "reset" smells somewhat wrong. Not that "matches" is any better, but at least the original says "to that of the tree", which you seem to have lost, so there is no indication what they are reset _to_. I don't think the above is a good change for this reason.

I also would prefer "are discarded" over "are lost". It is a conscious decision to use "git reset --hard" by the user in order to _do_ something, and "discard" is probably more accurate, in the sense that you use the command because you want to throw it away, than "lose" which implies you might have wanted to keep but did something wrong.

Show 10 quoted lines
>  --merge::
> -	Resets the index to match the tree recorded by the named commit,
> -	and updates the files that are different between the named commit
> -	and the current commit in the working tree.
> +	Resets the index and updates the files in the working tree that are
> +	different between <commit> and HEAD, but keeps those which are
> +	different between the index and working tree (i.e. which have unstaged
> +	changes).
> +	If a file that is different between <commit> and the index has unstaged
> +	changes, reset is aborted.

It may be just me, but "unstaged" sounds as if you once have staged and then changed your mind and took it back. "... which have changes that haven't been added" might be clearer.

Again, it is made unclear what these entities are _reset to_ with the above change. Same comments apply for your change to --keep.

Michael J Gruber· Sep 15, 2010, 20:47 UTC · re: Junio C Hamano · lore

Re: [PATCH 6/6] git-reset.txt: make modes description more consistent

Thanks for all your hints and thoughts. I'll be sending a v2 in a minute. There's just one point where I chose not to follow completely for now:

Junio C Hamano venit, vidit, dixit 14.09.2010 02:35:
> Michael J Gruber <git@drmicha.warpmail.net> writes:
[snip]
Show 15 quoted lines
>> @@ -57,22 +58,30 @@ linkgit:git-add[1]).
>>  	been updated. This is the default action.
>>  
>>  --hard::
>> -	Matches the working tree and index to that of the tree being
>> -	switched to. Any changes to tracked files in the working tree
>> -	since <commit> are lost.
>> +	Resets the index and working tree. Any changes to tracked files in the
>> +	working tree since <commit> are lost.
> 
> Explaining what "reset" does using the undefined word "reset" smells
> somewhat wrong.  Not that "matches" is any better, but at least the
> original says "to that of the tree", which you seem to have lost, so there
> is no indication what they are reset _to_.  I don't think the above is a
> good change for this reason.

The idea was to define "reset" once (in the paragraph right before the list of modes) and then use it without repeating that. I tried to make this a bit clearer now by emphasising the term "reset" more in the leading paragraph.

[snip]
> It may be just me, but "unstaged" sounds as if you once have staged and
> then changed your mind and took it back.  "... which have changes that
> haven't been added" might be clearer.

We use "unstaged" in the meaning of "not staged/added yet" in other places, as well - but in surprisingly few I have to admit! I went with your version here.

Michael
Jay Soffian· Sep 13, 2010, 22:15 UTC · re: Michael J Gruber · lore

Re: [PATCH 0/6] git-reset.txt improvements

On Mon, Sep 13, 2010 at 4:06 AM, Michael J Gruber <git@drmicha.warpmail.net> wrote:

Show 12 quoted lines
> First of all: I've been out of the loop last week, so please forgive me if this
> comes at the wrong phase of a cycle.
>
> I portioned the changes to git-reset.txt and ordered them starting from the
> least controversial, I hope. The descriptions of modes have grown organically
> over time, and this series tries to make them consistent in structure and
> wording, after cleaning up some minor issues. 6/6 is the "meat", so to say.
>
> For the "--merge" description in 6/6: Please double check. I've tried to
> understand the mode from the tables and from the inner works (git read-tre -u -m
> plus carrying over unmerged entries) because I did not understand the original
> description.

My quick read of these changes is that, all around, they are a big improvement to what I find to be one of git's most confusing man pages.

j.
Michael J Gruber· Sep 15, 2010, 20:47 UTC · re: Michael J Gruber · lore

[PATCHv2 0/6] git-reset.txt improvements

In v2 I tried to incorporate all changes as suggested by Junio. Thanks for all the hints!

Michael J Gruber (6):
  git-reset.txt: clarify branch vs. branch head
  git-reset.txt: reset does not change files in target
  git-reset.txt: reset --soft is not a no-op
  git-reset.txt: use "working tree" consistently
  git-reset.txt: point to git-checkout
  git-reset.txt: make modes description more consistent
 Documentation/git-reset.txt |   76 ++++++++++++++++++++++++++----------------
 1 files changed, 47 insertions(+), 29 deletions(-)
-- 
1.7.3.rc1.215.g6997c
Michael J Gruber· Sep 15, 2010, 20:47 UTC · re: Michael J Gruber · lore

[PATCHv2 1/6] git-reset.txt: clarify branch vs. branch head

"Change the branch" can be misunderstood to mean "change which branch is checked out". Make it clearer that git-reset changes the branch head of the currently checked out branch.

Signed-off-by: Michael J Gruber <git@drmicha.warpmail.net>
---
 Documentation/git-reset.txt |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)
Show changes to Documentation/git-reset.txt +2 −2
diff --git a/Documentation/git-reset.txt b/Documentation/git-reset.txt
index 9cf3148..91bd2e9 100644
--- a/Documentation/git-reset.txt
+++ b/Documentation/git-reset.txt
@@ -15,7 +15,7 @@ SYNOPSIS
 DESCRIPTION
 -----------
 In the first and second form, copy entries from <commit> to the index.
-In the third form, set the current branch to <commit>, optionally
+In the third form, set the current branch head to <commit>, optionally
 modifying index and worktree to match.  The <commit> defaults to HEAD
 in all forms.
 
@@ -36,7 +36,7 @@ This means that `git reset -p` is the opposite of `git add -p` (see
 linkgit:git-add[1]).
 
 'git reset' [--<mode>] [<commit>]::
-	This form points the current branch to <commit> and then
+	This form resets the current branch head to <commit> and then
 	updates index and working tree according to <mode>, which must
 	be one of the following:
 +
-- 
1.7.3.rc1.215.g6997c
Michael J Gruber· Sep 15, 2010, 20:47 UTC · re: Michael J Gruber · lore

[PATCHv2 2/6] git-reset.txt: reset does not change files in target

git-reset obviously cannot change files in an existing commit. Make it not sound as if it could: reset can change HEAD and, in that sense, can change which state a file in HEAD is in.

Signed-off-by: Michael J Gruber <git@drmicha.warpmail.net>
---
 Documentation/git-reset.txt |    6 ++++--
 1 files changed, 4 insertions(+), 2 deletions(-)
Show changes to Documentation/git-reset.txt +4 −2
diff --git a/Documentation/git-reset.txt b/Documentation/git-reset.txt
index 91bd2e9..e443740 100644
--- a/Documentation/git-reset.txt
+++ b/Documentation/git-reset.txt
@@ -294,8 +294,10 @@ In these tables, A, B, C and D are some different states of a
 file. For example, the first line of the first table means that if a
 file is in state A in the working tree, in state B in the index, in
 state C in HEAD and in state D in the target, then "git reset --soft
-target" will put the file in state A in the working tree, in state B
-in the index and in state D in HEAD.
+target" will leave the file in the working tree in state A and in the
+index in state B.  It resets (i.e. moves) the HEAD (i.e. the tip of
+the current branch, if you are on one) to "target" (which has the file
+in state D).
 
       working index HEAD target         working index HEAD
       ----------------------------------------------------
-- 
1.7.3.rc1.215.g6997c
Michael J Gruber· Sep 15, 2010, 20:47 UTC · re: Michael J Gruber · lore

[PATCHv2 3/6] git-reset.txt: reset --soft is not a no-op

Make it clearer that git reset --soft actually does something (changing HEAD). While it is mentioned in the previous paragraph already it can be easily overlooked otherwise.

Also, git reset --soft does not look at the index nor the worktree, so there is no "good order" requirement.

Signed-off-by: Michael J Gruber <git@drmicha.warpmail.net>
---
 Documentation/git-reset.txt |    8 ++++----
 1 files changed, 4 insertions(+), 4 deletions(-)
Show changes to Documentation/git-reset.txt +4 −4
diff --git a/Documentation/git-reset.txt b/Documentation/git-reset.txt
index e443740..8762a0c 100644
--- a/Documentation/git-reset.txt
+++ b/Documentation/git-reset.txt
@@ -42,10 +42,10 @@ linkgit:git-add[1]).
 +
 --
 --soft::
-	Does not touch the index file nor the working tree at all, but
-	requires them to be in a good order. This leaves all your changed
-	files "Changes to be committed", as 'git status' would
-	put it.
+	Does not touch the index file nor the working tree at all (but
+	resets the head to <commit>, just like all modes do). This leaves
+	all your changed files "Changes to be committed", as 'git status'
+	would put it.
 
 --mixed::
 	Resets the index but not the working tree (i.e., the changed files
-- 
1.7.3.rc1.215.g6997c
Michael J Gruber· Sep 15, 2010, 20:47 UTC · re: Michael J Gruber · lore

[PATCHv2 4/6] git-reset.txt: use "working tree" consistently

as per git help glossary
Signed-off-by: Michael J Gruber <git@drmicha.warpmail.net>
---
 Documentation/git-reset.txt |   14 +++++++-------
 1 files changed, 7 insertions(+), 7 deletions(-)
Show changes to Documentation/git-reset.txt +7 −7
diff --git a/Documentation/git-reset.txt b/Documentation/git-reset.txt
index 8762a0c..6c94f83 100644
--- a/Documentation/git-reset.txt
+++ b/Documentation/git-reset.txt
@@ -16,12 +16,12 @@ DESCRIPTION
 -----------
 In the first and second form, copy entries from <commit> to the index.
 In the third form, set the current branch head to <commit>, optionally
-modifying index and worktree to match.  The <commit> defaults to HEAD
+modifying index and working tree to match.  The <commit> defaults to HEAD
 in all forms.
 
 'git reset' [-q] [<commit>] [--] <paths>...::
 	This form resets the index entries for all <paths> to their
-	state at the <commit>.  (It does not affect the worktree, nor
+	state at the <commit>.  (It does not affect the working tree, nor
 	the current branch.)
 +
 This means that `git reset <paths>` is the opposite of `git add
@@ -184,7 +184,7 @@ tip of the current branch in ORIG_HEAD, so resetting hard to it
 brings your index file and the working tree back to that state,
 and resets the tip of the branch to that commit.
 
-Undo a merge or pull inside a dirty work tree::
+Undo a merge or pull inside a dirty working tree::
 +
 ------------
 $ git pull                         <1>
@@ -257,7 +257,7 @@ Suppose you are working on something and you commit it, and then you
 continue working a bit more, but now you think that what you have in
 your working tree should be in another branch that has nothing to do
 with what you committed previously. You can start a new branch and
-reset it while keeping the changes in your work tree.
+reset it while keeping the changes in your working tree.
 +
 ------------
 $ git tag start
@@ -348,11 +348,11 @@ in state D).
 				--keep   B       C     C
 
 "reset --merge" is meant to be used when resetting out of a conflicted
-merge. Any mergy operation guarantees that the work tree file that is
+merge. Any mergy operation guarantees that the working tree file that is
 involved in the merge does not have local change wrt the index before
-it starts, and that it writes the result out to the work tree. So if
+it starts, and that it writes the result out to the working tree. So if
 we see some difference between the index and the target and also
-between the index and the work tree, then it means that we are not
+between the index and the working tree, then it means that we are not
 resetting out from a state that a mergy operation left after failing
 with a conflict. That is why we disallow --merge option in this case.
 
-- 
1.7.3.rc1.215.g6997c
Michael J Gruber· Sep 15, 2010, 20:47 UTC · re: Michael J Gruber · lore

[PATCHv2 5/6] git-reset.txt: point to git-checkout

for the case of updating a file in index and worktree, or from the index to the worktree.

Signed-off-by: Michael J Gruber <git@drmicha.warpmail.net>
---
 Documentation/git-reset.txt |    7 +++++++
 1 files changed, 7 insertions(+), 0 deletions(-)
Show changes to Documentation/git-reset.txt +7 −0
diff --git a/Documentation/git-reset.txt b/Documentation/git-reset.txt
index 6c94f83..78f3b74 100644
--- a/Documentation/git-reset.txt
+++ b/Documentation/git-reset.txt
@@ -26,6 +26,13 @@ in all forms.
 +
 This means that `git reset <paths>` is the opposite of `git add
 <paths>`.
++
+After running `git reset <paths>` to update the index entry, you can
+use linkgit:git-checkout[1] to check the contents out of the index to
+the working tree.
+Alternatively, using linkgit:git-checkout[1] and specifying a commit, you
+can copy the contents of a path out of a commit to the index and to the
+working tree in one go.
 
 'git reset' --patch|-p [<commit>] [--] [<paths>...]::
 	Interactively select hunks in the difference between the index
-- 
1.7.3.rc1.215.g6997c
Michael J Gruber· Sep 15, 2010, 20:47 UTC · re: Michael J Gruber · lore

[PATCHv2 6/6] git-reset.txt: make modes description more consistent

Currently, the structure of the individual mode entries is different which makes it difficult to grasp the differences between the modes. Also, the same items are named differently (e.g. <commit>, "the named commit", "the given commit", "the commit being switched to").

Structure and word all mode entries consistently.
Signed-off-by: Michael J Gruber <git@drmicha.warpmail.net>
Conflicts:
	Documentation/git-reset.txt
Signed-off-by: Michael J Gruber <git@drmicha.warpmail.net>
---
 Documentation/git-reset.txt |   43 ++++++++++++++++++++++++++-----------------
 1 files changed, 26 insertions(+), 17 deletions(-)
Show changes to Documentation/git-reset.txt +26 −17
diff --git a/Documentation/git-reset.txt b/Documentation/git-reset.txt
index 78f3b74..fd72976 100644
--- a/Documentation/git-reset.txt
+++ b/Documentation/git-reset.txt
@@ -15,13 +15,13 @@ SYNOPSIS
 DESCRIPTION
 -----------
 In the first and second form, copy entries from <commit> to the index.
-In the third form, set the current branch head to <commit>, optionally
+In the third form, set the current branch head (HEAD) to <commit>, optionally
 modifying index and working tree to match.  The <commit> defaults to HEAD
 in all forms.
 
 'git reset' [-q] [<commit>] [--] <paths>...::
 	This form resets the index entries for all <paths> to their
-	state at the <commit>.  (It does not affect the working tree, nor
+	state at <commit>.  (It does not affect the working tree, nor
 	the current branch.)
 +
 This means that `git reset <paths>` is the opposite of `git add
@@ -43,9 +43,10 @@ This means that `git reset -p` is the opposite of `git add -p` (see
 linkgit:git-add[1]).
 
 'git reset' [--<mode>] [<commit>]::
-	This form resets the current branch head to <commit> and then
-	updates index and working tree according to <mode>, which must
-	be one of the following:
+	This form resets the current branch head to <commit> and
+	possibly updates the index (resetting it to the tree of <commit>) and
+	the working tree depending on <mode>, which
+	must be one of the following:
 +
 --
 --soft::
@@ -60,22 +61,30 @@ linkgit:git-add[1]).
 	been updated. This is the default action.
 
 --hard::
-	Matches the working tree and index to that of the tree being
-	switched to. Any changes to tracked files in the working tree
-	since <commit> are lost.
+	Resets the index and working tree. Any changes to tracked files in the
+	working tree since <commit> are discarded.
 
 --merge::
-	Resets the index to match the tree recorded by the named commit,
-	and updates the files that are different between the named commit
-	and the current commit in the working tree.
+	Resets the index and updates the files in the working tree that are
+	different between <commit> and HEAD, but keeps those which are
+	different between the index and working tree (i.e. which have changes
+	which have not been added).
+	If a file that is different between <commit> and the index has unstaged
+	changes, reset is aborted.
++
+In other words, --merge does something like a 'git read-tree -u -m <commit>',
+but carries forward unmerged index entries.
 
 --keep::
-	Reset the index to the given commit, keeping local changes in
-	the working tree since the current commit, while updating
-	working tree files without local changes to what appears in
-	the given commit.  If a file that is different between the
-	current commit and the given commit has local changes, reset
-	is aborted.
+	Resets the index, updates files in the working tree that are
+	different between <commit> and HEAD, but keeps those
+	which are different between HEAD and the working tree (i.e.
+	which have local changes).
+	If a file that is different between <commit> and HEAD has local changes,
+	reset is aborted.
++
+In other words, --keep does a 2-way merge between <commit> and HEAD followed by
+'git reset --mixed <commit>'.
 --
 
 If you want to undo a commit other than the latest on a branch,
-- 
1.7.3.rc1.215.g6997c

← back to recent threads