git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH] git-revert is one of the most misunderstood command in git, help users out.

From
Pierre Habouzit <madcoder@debian.org>
Date
Nov 6, 2007, 12:48 UTC
Message-ID
<20071106124833.GA25637@artemis.corp>
In-Reply-To
<Pine.LNX.4.64.0711061216330.4362@racer.site>
On Tue, Nov 06, 2007 at 12:25:33PM +0000, Johannes Schindelin wrote:
Show 36 quoted lines
> Hi,
>
> On Tue, 6 Nov 2007, Junio C Hamano wrote:
>
> > Junio C Hamano <gitster@pobox.com> writes:
> >
> > > Johannes Schindelin <Johannes.Schindelin@gmx.de> writes:
> > >
> > >> In the same way, I would expect "git revert <commit> -- file" to undo the
> > >> changes in that commit to _that_ file (something like "git merge-file
> > >> file <commit>:file <commit>^:file"), but this time commit it, since it
> > >> was committed at one stage.
> > >
> > > Allowing people to revert or cherry pick partially by using
> > > paths limiter is a very good idea; ...
> >
> > As Pierre said earlier, a partial revert via "revert <commit> --
> > <paths>" and a partial cherry-pick would make quite a lot of
> > sense, and in addition, it should not be too hard to add.
>
> Yes, but Pierre also said earlier that people want to revert their local
> changes.  And the logical thing to try that really is
>
> 	git revert <path>
>
> Now, if you read that out in English, it does not make too much sense:
> "revert the path" (not "revert the _changes_ to that file").  But it is
> what people try to do.
>
> However, IIUC another thing Pierre mentioned is that
>
> 	$scm revert <commit> <path>
>
> commonly means "revert the file _to the version_ stored in <commit>".
> This is just different enough from "revert the _changes_ to that file
> stored in <commit>" to bite people, no?
  Yeah but that's what checkout is for. The main source of iritation for
new users comes (IMHO) from svn, where `svn revert path/to/file` is part
of the workflow: in case of a conflict when you `svn up`, you have
either to:
  (1) fix the conflict and `svn resolved path/to/file`
  (2) drop your changes and take the trunk version `svn revert path/to/file`

People really expect git revert -- path/to/file to do the same as git checkout HEAD -- path/to/file. Though I believe that like I said, maybe we don't wan't git revert -- path/to/file to become the first class command to do that, but rather to do what the user meant, hinting him in the direction of the proper command. I wasn't really advocating that git-revert should be a complete implementation of what git checkout <comitish> -- <paths> does. YMMV.

-- ·O· Pierre Habouzit ··O madcoder@debian.org OOO http://www.madism.org

Previous: Johannes SchindelinNext: Wincent Colaiuta
Message 38 of 39 in “git-revert is one of the most misunderstood command in git, help users out.”
  1. git-revert is one of the most misunderstood command in git, help users out.Pierre Habouzit, Nov 5, 2007
  2. Pierre HabouzitNov 5, 2007
  3. J. Bruce FieldsNov 5, 2007
  4. Pierre HabouzitNov 5, 2007
  5. Steven GrimmNov 5, 2007
  6. Pierre HabouzitNov 5, 2007
  7. Alejandro Martinez RuizNov 5, 2007
  8. David KastrupNov 5, 2007
  9. Alejandro Martinez RuizNov 5, 2007
  10. Junio C HamanoNov 5, 2007
  11. Johannes SchindelinNov 5, 2007
  12. Pierre HabouzitNov 6, 2007
  13. Junio C HamanoNov 6, 2007
  14. Johannes SchindelinNov 6, 2007
  15. Junio C HamanoNov 6, 2007
  16. Pierre HabouzitNov 6, 2007
  17. Mike HommeyNov 6, 2007
  18. Pierre HabouzitNov 6, 2007
  19. Johannes SchindelinNov 6, 2007
  20. Junio C HamanoNov 6, 2007
  21. Johannes SchindelinNov 6, 2007
  22. Pierre HabouzitNov 6, 2007
  23. Junio C HamanoNov 6, 2007
  24. Johannes SchindelinNov 6, 2007
  25. Robin RosenbergNov 6, 2007
  26. Mike HommeyNov 6, 2007
  27. Robin RosenbergNov 6, 2007
  28. Johannes SchindelinNov 6, 2007
  29. Mike HommeyNov 7, 2007
  30. Johannes SchindelinNov 7, 2007
  31. Robin RosenbergNov 7, 2007
  32. Jakub NarebskiNov 7, 2007
  33. David KastrupNov 7, 2007
  34. Junio C HamanoNov 6, 2007
  35. Johannes SixtNov 6, 2007
  36. Johannes SchindelinNov 6, 2007
  37. Johannes SchindelinNov 6, 2007
  38. Pierre HabouzitNov 6, 2007
  39. Wincent ColaiutaNov 6, 2007

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.