{"thread":{"id":"22530","subject":"Re: reverting vs resetting","startedAt":"2010-02-05T06:12:23Z","lastAt":"2010-02-05T11:21:01Z","messageCount":5,"participants":["Avery Pennarun","Mihamina Rakotomandimby","Junio C Hamano","Matthieu Moy"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"133666","messageId":"20100205091223.6b4cffb1@pbmiha.malagasy.com","threadId":"22530","inReplyTo":null,"subject":"reverting vs resetting","fromName":"Mihamina Rakotomandimby","fromEmail":"mihamina@gulfsat.mg","sentAt":"2010-02-05T06:12:23Z","receivedAt":"2010-02-05T06:12:23Z","isPatch":false,"sender":{"key":"mihamina@gulfsat.mg","avatar":null},"body":"Manao ahoana, Hello, Bonjour,\n\nWe put a gateway iptables script (SNAT, DNAT,...) under GIT.\n\nSomeone (Bob) made a mistake on it, but he did not know. That broke the\ngateway.\n\nAnother one (Andy), did not try to undo Bob's mistake but tried (and\ntried, and tried... always committing) to solve the problem. Andy made\nabout 50 commits.\n\nWhen we decided to giveup, we decided to get back to the configuration\nbefore Bob broke it. But it would be interesting to see Andy's history.\n\nReverting or resetting?\n\nAs far as I know: \n- Reverting Bob's commit will only cancel Bob's mistake but not Andy's\n  tries to solve it.\n- Resetting will forget the history.\n\nAny suggestion?\n\nMisaotra, Thanks, Merci.\n\n-- \n       Architecte Informatique chez Blueline/Gulfsat:\n    Administration Systeme, Recherche & Developpement\n                +261 34 29 155 34 / +261 33 11 207 36\n"},{"id":"133665","messageId":"32541b131002042248x5461d904r276b184533ac492a@mail.gmail.com","threadId":"22530","inReplyTo":"20100205091223.6b4cffb1@pbmiha.malagasy.com","subject":"Re: reverting vs resetting","fromName":"Avery Pennarun","fromEmail":"apenwarr@gmail.com","sentAt":"2010-02-05T06:48:07Z","receivedAt":"2010-02-05T06:48:07Z","isPatch":false,"sender":{"key":"apenwarr@gmail.com","avatar":"https://avatars.githubusercontent.com/u/20592?v=4"},"body":"On Fri, Feb 5, 2010 at 1:12 AM, Mihamina Rakotomandimby\n<mihamina@gulfsat.mg> wrote:\n> When we decided to giveup, we decided to get back to the configuration\n> before Bob broke it. But it would be interesting to see Andy's history.\n>\n> Reverting or resetting?\n\nTry this:\n\n    git checkout HEAD~5 .\n    git commit -m \"reverted back to the version before this mess\"\n\nReplace HEAD~5 with the revision you want it to look like.  But don't\nforget the \".\" in the checkout line!  All the magic is in there.  When\nyou specify a path (\".\"), git won't change the revision HEAD points\nto, but it will change all the files and the index to the ones from\nthe specified version.  Then you can commit these files, producing\neffectively a single commit that undoes a bunch of previous ones.\n\nHave fun,\n\nAvery\n"},{"id":"133671","messageId":"7v1vh0jh0p.fsf@alter.siamese.dyndns.org","threadId":"22530","inReplyTo":"32541b131002042248x5461d904r276b184533ac492a@mail.gmail.com","subject":"Re: reverting vs resetting","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2010-02-05T07:09:10Z","receivedAt":"2010-02-05T07:09:10Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Avery Pennarun <apenwarr@gmail.com> writes:\n\n> On Fri, Feb 5, 2010 at 1:12 AM, Mihamina Rakotomandimby\n> <mihamina@gulfsat.mg> wrote:\n>> When we decided to giveup, we decided to get back to the configuration\n>> before Bob broke it. But it would be interesting to see Andy's history.\n>>\n>> Reverting or resetting?\n>\n> Try this:\n>\n>     git checkout HEAD~5 .\n>     git commit -m \"reverted back to the version before this mess\"\n\nCaveat: if Andy added new paths while experimenting, the above won't\nremove it.  You would need something like this instead:\n\n\tgit read-tree -m -u HEAD~50\n        git commit -m \"reverted back to the version before this mess\"\n\nBut this all assumes that the futile experiment is worth keeping.  I\nhighly doubt it.\n\nI would recommend to do this:\n\n\tgit branch andy_failed_experiment\n        git reset --hard HEAD~50\n\t;# and perhaps revert Bob's change here as well\n\nThere is no sane reason to keep the failed experiment that added nothing\nof value to the history leading to the tip of the 'master' branch.\n\nI am using the word _value_ but keep in mind that value is relative to the\npurpose you have in mind.  The purpose of the 'master' branch presumably\nis to keep and to improve on a working configuration of the gateway box.\nFor that particular purpose, you have to admit that Andy's futzing around\ndidn't add anything of value in the result.  Hence, that shouldn't be kept\nin its history.\n\nAndy and other people may be able to learn from the failed experiment\nlater, so it is perfectly Ok to keep the series of random hacks in a\nseparate branch to study at their leisure.  The purpose of the branch is\ndifferent from that of the 'master': it is to serve as a catalog of\nthings/ideas that did _not_ work.\n"},{"id":"133674","messageId":"vpqwryskrbi.fsf@bauges.imag.fr","threadId":"22530","inReplyTo":"7v1vh0jh0p.fsf@alter.siamese.dyndns.org","subject":"Re: reverting vs resetting","fromName":"Matthieu Moy","fromEmail":"matthieu.moy@grenoble-inp.fr","sentAt":"2010-02-05T08:41:21Z","receivedAt":"2010-02-05T08:41:21Z","isPatch":false,"sender":{"key":"matthieu.moy@grenoble-inp.fr","avatar":"https://gravatar.com/avatar/72c8a2705971a25dfaff23cece15130d405685845d911aedd5667ace277f3fc5?d=mp&s=160"},"body":"Junio C Hamano <gitster@pobox.com> writes:\n\n> \tgit branch andy_failed_experiment\n>         git reset --hard HEAD~50\n> \t;# and perhaps revert Bob's change here as well\n\nSo would I, and to complement Junio's answer: keeping a failure\nfollowed by a repair means this experiment will appear more or less\nforever in the output of \"git log\", \"git blame\", will break \"git\nbisect\" on that part of history, and so on. Putting it on a separate\nbranch avoids this, and keeps it in a safe place to show newcommers:\n\"see, here's what you should not do\" ;-).\n\n-- \nMatthieu Moy\nhttp://www-verimag.imag.fr/~moy/\n"},{"id":"133677","messageId":"20100205142101.7d1fbcb1@pbmiha.malagasy.com","threadId":"22530","inReplyTo":"vpqwryskrbi.fsf@bauges.imag.fr","subject":"Re: reverting vs resetting","fromName":"Mihamina Rakotomandimby","fromEmail":"mihamina@gulfsat.mg","sentAt":"2010-02-05T11:21:01Z","receivedAt":"2010-02-05T11:21:01Z","isPatch":false,"sender":{"key":"mihamina@gulfsat.mg","avatar":null},"body":"> Matthieu Moy <Matthieu.Moy@grenoble-inp.fr> :\n> So would I, and to complement Junio's answer\n\nThank you all.\n\n-- \n       Architecte Informatique chez Blueline/Gulfsat:\n    Administration Systeme, Recherche & Developpement\n                +261 34 29 155 34 / +261 33 11 207 36\n"}]}