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

3 messages from 2008-04-02 to 2008-04-02. Participants: Ittay Dror, Johannes Sixt, Junio C Hamano.
Thread: https://gitlist.dev/t/12960

## Ittay Dror, 2008-04-02 06:50

Subject: how do i revert to a previous version, keeping the history
Message-ID: <47F32CBE.2040305@tikalk.com>
URL: https://gitlist.dev/e/47F32CBE.2040305%40tikalk.com

```
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

-- 
Ittay Dror <ittayd@tikalk.com>
Tikal <http://www.tikalk.com>
Tikal Project <http://tikal.sourceforge.net>

```

## Johannes Sixt, 2008-04-02 06:57

Subject: Re: how do i revert to a previous version, keeping the history
Message-ID: <47F32E66.1010705@viscovery.net>
URL: https://gitlist.dev/e/47F32E66.1010705%40viscovery.net
In-Reply-To: <47F32CBE.2040305@tikalk.com>

```
Ittay Dror schrieb:
> 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

```

## Junio C Hamano, 2008-04-02 07:12

Subject: Re: how do i revert to a previous version, keeping the history
Message-ID: <7vfxu4afwr.fsf@gitster.siamese.dyndns.org>
URL: https://gitlist.dev/e/7vfxu4afwr.fsf%40gitster.siamese.dyndns.org
In-Reply-To: <47F32CBE.2040305@tikalk.com>

```
Ittay Dror <ittayd@tikalk.com> writes:

> 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.

```
