Skip to contentSkip to conversation

how do i revert to a previous version, keeping the history

DISCUSSION Ittay Dror 3 participants 3 messages Jun 15, 2016

lore
Share & tools
lore

Ittay Dror

author
#0 lore raw

Hi,

I have this revision history: A-B
I want to go back to the code in A, but keep B in the history: A-B-A

How do I do that?

Thank you,
Ittay

Signature · 3 lines
Ittay Dror <[email protected]>
Tikal <http://www.tikalk.com>
Tikal Project <http://tikal.sourceforge.net>
#1 lore raw
Quoted 4 lines · Ittay Dror

I have this revision history: A-B
I want to go back to the code in A, but keep B in the history: A-B-A

How do I do that?

git revert HEAD

-- Hannes

#2 lore raw
In reply to Ittay Dror
Quoted 4 lines · Ittay Dror

I have this revision history: A-B
I want to go back to the code in A, but keep B in the history: A-B-A

How do I do that?

Straight answer (iow, what you asked, which may not match what you wanted to really do):

	$ git read-tree -m -u A
        $ git commit -m 'Revert to A'

Probably a more useful answer, guessing what you really wanted to do:

You have a botched commit F that was in the sequence of longer commits, A--B--C--D--E--F--G--H, and you want to recover from the mistake F made (iow, the change between E and F is bad):

	$ git revert F

This will make your history A--B--C--D--E--F--G--H--F' where the difference between H and F' counteracts what F did relative to E.