Thread (27 messages) flat view 27 messages, 12 authors, 2016-06-15

Re: Rollback of git commands

From: Junio C Hamano <hidden>
Date: 2016-06-15 22:43:54

"Jon Smirl" [off-list ref] 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.
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help