[PATCH] Add hints to revert documentation about other ways to undo changes

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Based on its name, people may read the 'git revert' documentation when
they want to undo local changes, especially people who have used other
SCM's.  'git revert' may not be what they had in mind, but git
provides several other ways to undo changes to files.  We can help
them by pointing them towards the git commands that do what they might
want to do.

Cc: Daniel Barkalow <barkalow@xxxxxxxxxxxx>
Cc: Lea Wiemann <lewiemann@xxxxxxxxx>
Signed-off-by: Tarmigan Casebolt <tarmigan+git@xxxxxxxxx>
---

On Tue, Aug 19, 2008 at 11:56 AM, Junio C Hamano <gitster@xxxxxxxxx> wrote:
> The last sentence makes the paragraph incoherent, doesn't it?

Yeah.  My thinking was that the people who would appreciate this note
would be newbies, and it might be nice to warn them not to just try
'git reset --hard' without thinking.

> By starting this paragraph with "Despite its name", you are stating your
> expectation that the people who find "git revert" nonintuitive are the
> majority.  
>
> And you explain how to perform the operation that majority
> would expect, which is to throw away uncommitted changes to go back to the
> clean slate.  If that is what the target audience of this paragraph
> expects to happen anyway, why do you need to caution against it in the
> last sentence?

I envision this note as useful for a majority of newbies who don't yet
have a sense of everything 'git reset' and 'git checkout' can do.

> If the answer is "because it is not cut-and-dried which expectation is the
> majority, and we try to be careful not to lose local modifications of
> users", then the tone of the paragraph needs to become more neutral.
>
> I'd suggest either dropping the first sentence altogether and starting the
> paragraph with "If you want to throw away...", or replacing the first
> sentence with "'git revert' is used to record a new commit to reverse the
> effect of an earlier commit (often a faulty one)."

Good idea.  I like the later option.

Thanks,
Tarmigan

 Documentation/git-revert.txt |    9 +++++++++
 1 files changed, 9 insertions(+), 0 deletions(-)

diff --git a/Documentation/git-revert.txt b/Documentation/git-revert.txt
index 98cfa3c..e578edf 100644
--- a/Documentation/git-revert.txt
+++ b/Documentation/git-revert.txt
@@ -15,7 +15,15 @@ Given one existing commit, revert the change the patch introduces, and record a
 new commit that records it.  This requires your working tree to be clean (no
 modifications from the HEAD commit).
 
+Note: 'git revert' is used to record a new commit to reverse the
+effect of an earlier commit (often a faulty one).  If you want to
+throw away all uncommitted changes in your working directory, you
+should see linkgit:git-reset[1], particularly the '--hard' option.  If
+you want to extract specific files as they were in another commit, you
+should see linkgit:git-checkout[1], specifically the 'git checkout
+<commit> -- <filename>' syntax.  Take care with these alternatives as
+both will discard uncommitted changes in your working directory.
+
 OPTIONS
 -------
 <commit>::
-- 
1.6.0

--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux