{"thread":{"id":"12960","subject":"how do i revert to a previous version, keeping the history","startedAt":"2008-04-02T06:50:38Z","lastAt":"2008-04-02T07:12:52Z","messageCount":3,"participants":["Ittay Dror","Johannes Sixt","Junio C Hamano"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"73534","messageId":"47F32CBE.2040305@tikalk.com","threadId":"12960","inReplyTo":null,"subject":"how do i revert to a previous version, keeping the history","fromName":"Ittay Dror","fromEmail":"ittayd@tikalk.com","sentAt":"2008-04-02T06:50:38Z","receivedAt":"2008-04-02T06:50:38Z","isPatch":false,"sender":{"key":"ittayd@tikalk.com","avatar":null},"body":"Hi,\n\nI have this revision history: A-B\nI want to go back to the code in A, but keep B in the history: A-B-A\n\nHow do I do that?\n\nThank you,\nIttay\n\n-- \nIttay Dror <ittayd@tikalk.com>\nTikal <http://www.tikalk.com>\nTikal Project <http://tikal.sourceforge.net>\n"},{"id":"73536","messageId":"47F32E66.1010705@viscovery.net","threadId":"12960","inReplyTo":"47F32CBE.2040305@tikalk.com","subject":"Re: how do i revert to a previous version, keeping the history","fromName":"Johannes Sixt","fromEmail":"j.sixt@viscovery.net","sentAt":"2008-04-02T06:57:42Z","receivedAt":"2008-04-02T06:57:42Z","isPatch":false,"sender":{"key":"j6t@kdbg.org","avatar":"https://avatars.githubusercontent.com/u/14810926?v=4"},"body":"Ittay Dror schrieb:\n> I have this revision history: A-B\n> I want to go back to the code in A, but keep B in the history: A-B-A\n> \n> How do I do that?\n\ngit revert HEAD\n\n-- Hannes\n"},{"id":"73538","messageId":"7vfxu4afwr.fsf@gitster.siamese.dyndns.org","threadId":"12960","inReplyTo":"47F32CBE.2040305@tikalk.com","subject":"Re: how do i revert to a previous version, keeping the history","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2008-04-02T07:12:52Z","receivedAt":"2008-04-02T07:12:52Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Ittay Dror <ittayd@tikalk.com> writes:\n\n> I have this revision history: A-B\n> I want to go back to the code in A, but keep B in the history: A-B-A\n>\n> How do I do that?\n\nStraight answer (iow, what you asked, which may not match what you wanted\nto really do):\n\n\t$ git read-tree -m -u A\n        $ git commit -m 'Revert to A'\n\nProbably a more useful answer, guessing what you really wanted to do:\n\nYou have a botched commit F that was in the sequence of longer commits,\nA--B--C--D--E--F--G--H, and you want to recover from the mistake F made\n(iow, the change between E and F is bad):\n\n\t$ git revert F\n\nThis will make your history A--B--C--D--E--F--G--H--F' where the\ndifference between H and F' counteracts what F did relative to E.\n"}]}