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

Re: Revert behavior [Was: Re: [ANNOUNCE] yap: Yet Another (Git) Porcelain]

From
GSGovind Salinas <govind@sophiasuchtig.com>
Date
Sep 9, 2008, 16:37 UTC
Message-ID
<5d46db230809090937k44fc569ct7eda35b9ee86cb22@mail.gmail.com>
In-Reply-To
<200809091538.13961.jnareb@gmail.com>
On Tue, Sep 9, 2008 at 8:38 AM, Jakub Narebski <jnareb@gmail.com> wrote:
Show 27 quoted lines
> Elijah Newren wrote:
>> On Mon, Sep 8, 2008 at 10:25 PM, Govind Salinas
>> <govind@sophiasuchtig.com> wrote:
>> > On Mon, Sep 8, 2008 at 8:05 PM, Steven Walter <stevenrwalter@gmail.com> wrote:
>>
>> > I had some very different ideas along the lines of reducing the number of
>> > commands (where the commands do something similar just DWIM rather
>> > than force me to remember or read docs on different commands), making
>> > commands look similar to commands from other SCMs (revert should do
>> > what it does for me in all the other SCMs that I have used, which is to
>> > checkout the HEAD copy into the working directory)
>>
>> Your description of revert in various systems isn't quite accurate; it
>> isn't necessarily HEAD, since most systems (at least bzr and hg) can
>> also revert files to revisions earlier than HEAD.  In fact, questions
>> of how to do that have come up several times on this list, so you
>> wouldn't want to exclude that case.  Also, the revert behavior of git
>> (minus perhaps the default auto-commit) comes in pretty handy too
>> sometimes, and I can't easily find it in other systems (I suspect many
>> just drop back to diff + patch to handle the case that git provides).
> [...]
>
> By the way, I think the fact that in different SCMs meaning of
> "$scm revert" and of "$scm reset" differs widely caused Mercurial
> to adopt "hg backout" for creating a commit which reverts changes
> (cherry-pick -R), and "hg rollback" to undo last commit.
>

My take on this comes from my own personal experience with "revert" commands, the fact that "how do i undo my working dir changes" is the most common question I see on the list and that I have heard others with the same complaint.

I will concede that revert usually means both "discard current working dir changes" and "undo a previous change" in different circumstances. However, the number of times that "how do i discard my working dir changes" comes up on the list leads me to believe that you get the most out of using revert for this, since it is something that should be familiar to a user and undoing a previous commit is more rare.

Of course, this is where I would use a DWIM-ism. "pyt revert -r commitish" would generate a reverse patch but "pyt revert <paths>..." would checkout from HEAD. "pyt revert" would just "git reset --hard".

-Govind
Previous: Jakub NarebskiNext: Steven Walter
Message 3 of 13 in “Revert behavior [Was: Re: [ANNOUNCE] yap: Yet Another (Git) Porcelain]”
  1. Elijah NewrenSep 9, 2008
  2. Jakub NarebskiSep 9, 2008
  3. Govind SalinasSep 9, 2008
  4. Steven WalterSep 9, 2008
  5. Elijah NewrenSep 9, 2008
  6. Steven WalterSep 9, 2008
  7. Elijah NewrenSep 9, 2008
  8. Elijah NewrenSep 9, 2008
  9. Petr BaudisSep 9, 2008
  10. Steven WalterSep 9, 2008
  11. Junio C HamanoSep 9, 2008
  12. Steven WalterSep 9, 2008
  13. Elijah NewrenSep 9, 2008

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.