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

Re: Rollback of git commands

From
Junio C Hamano <gitster@pobox.com>
Date
Nov 28, 2007, 00:51 UTC
Message-ID
<7vmyszb39s.fsf@gitster.siamese.dyndns.org>
In-Reply-To
<9e4733910711271523p3be94010jac9c79e6b95f010d@mail.gmail.com>
"Jon Smirl" <jonsmirl@gmail.com> writes:
> Could a rollback log be implemented in git? It would make things way
> easier when you screw something up. You'd only roll back things that
> impacted the object store, not things like checkout.

The object store is append only, and if you disregard SHA-1 collisions, I do not think there is much you can gain from being able to roll back only object store.

For example, you would want to be able to roll back where your 'master' branch was pointing at before you started that botched operation. That is not in the object store at all (we have reflogs for that).

Another example, you might have done quite an elaborate interactive add to stage only some changes to a path, but then accidentally said "git add" that path to stage the whole thing. You may say "oops, that state was only in the index and now it is lost." The blob that records the staged content _DOES_ exist in the object store in such a case so it is not lost --- there is nothing to roll back. What you lost is a pointer into the object store (we do not have anything like reflog for individual index entry --- not that I would suggest adding one).

Creating a blob that records all of .git/config, output from for-each-ref, output from "symbolic-ref HEAD" and output from ls-files -s every time you run _any_ git operation, and restore the state when you want to, would conceptually work, as you suggest, but I am not sure how practical it would be, performancewise, spacewise, and semanticswise.

Previous: Jon SmirlNext: Jon Smirl
Message 2 of 31 in “Rollback of git commands”
  1. Jon SmirlNov 27, 2007
  2. Junio C HamanoNov 28, 2007
  3. Jon SmirlNov 28, 2007
  4. Jon SmirlNov 28, 2007
  5. David SymondsNov 28, 2007
  6. Ingo MolnarNov 28, 2007
  7. Sergei OrganovNov 28, 2007
  8. Nicolas PitreNov 28, 2007
  9. Geert BoschNov 28, 2007
  10. Jeff KingNov 28, 2007
  11. Jon SmirlNov 28, 2007
  12. Jeff KingNov 28, 2007
  13. SeanNov 28, 2007
  14. Jon SmirlNov 28, 2007
  15. SeanNov 28, 2007
  16. Jon SmirlNov 28, 2007
  17. Nicolas PitreNov 28, 2007
  18. Jon SmirlNov 28, 2007
  19. Nicolas PitreNov 28, 2007
  20. Jon SmirlNov 28, 2007
  21. Nicolas PitreNov 28, 2007
  22. Jon SmirlNov 28, 2007
  23. Karl HasselströmNov 29, 2007
  24. Junio C HamanoNov 28, 2007
  25. Karl HasselströmNov 28, 2007
  26. Jon SmirlNov 28, 2007
  27. Daniel BarkalowNov 28, 2007
  28. Steven GrimmNov 28, 2007
  29. Daniel BarkalowNov 28, 2007
  30. Jon SmirlNov 28, 2007
  31. Theodore TsoNov 29, 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.