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

Re: reverting vs resetting

From
Avery Pennarun <apenwarr@gmail.com>
Date
Feb 5, 2010, 06:48 UTC
Message-ID
<32541b131002042248x5461d904r276b184533ac492a@mail.gmail.com>
In-Reply-To
<20100205091223.6b4cffb1@pbmiha.malagasy.com>

On Fri, Feb 5, 2010 at 1:12 AM, Mihamina Rakotomandimby <mihamina@gulfsat.mg> wrote:

> When we decided to giveup, we decided to get back to the configuration
> before Bob broke it. But it would be interesting to see Andy's history.
>
> Reverting or resetting?
Try this:
    git checkout HEAD~5 .
    git commit -m "reverted back to the version before this mess"

Replace HEAD~5 with the revision you want it to look like. But don't forget the "." in the checkout line! All the magic is in there. When you specify a path ("."), git won't change the revision HEAD points to, but it will change all the files and the index to the ones from the specified version. Then you can commit these files, producing effectively a single commit that undoes a bunch of previous ones.

Have fun,
Avery
Previous: Mihamina RakotomandimbyNext: Junio C Hamano
Message 2 of 5 in “reverting vs resetting”
  1. Mihamina RakotomandimbyFeb 5, 2010
  2. Avery PennarunFeb 5, 2010
  3. Junio C HamanoFeb 5, 2010
  4. Matthieu MoyFeb 5, 2010
  5. Mihamina RakotomandimbyFeb 5, 2010

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.