{"thread":{"id":"33388","subject":"reverting changes","startedAt":"2013-04-04T22:03:57Z","lastAt":"2013-04-04T22:19:17Z","messageCount":2,"participants":["Thiago Farina","Junio C Hamano"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"213208","messageId":"CACnwZYe45poRihJToDY5yrLeY-wc=6HSjZBanjGvtiopbuAAFw@mail.gmail.com","threadId":"33388","inReplyTo":null,"subject":"reverting changes","fromName":"Thiago Farina","fromEmail":"tfransosi@gmail.com","sentAt":"2013-04-04T22:03:57Z","receivedAt":"2013-04-04T22:03:57Z","isPatch":false,"sender":{"key":"tfransosi@gmail.com","avatar":"https://avatars.githubusercontent.com/u/970071?v=4"},"body":"Hi,\n\nWhen I want to revert a change to a file that is already committed\nwhat is the best way?\n\nThe way I found was:\n\n$ git checkout HEAD /path/to/my/file\n$ git reset HEAD /path/to/my/file\n\nIs this the canonical/best way or there other (easier-faster) ways?\n\nThanks,\n"},{"id":"213212","messageId":"7v8v4ygcre.fsf@alter.siamese.dyndns.org","threadId":"33388","inReplyTo":"CACnwZYe45poRihJToDY5yrLeY-wc=6HSjZBanjGvtiopbuAAFw@mail.gmail.com","subject":"Re: reverting changes","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2013-04-04T22:19:17Z","receivedAt":"2013-04-04T22:19:17Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Thiago Farina <tfransosi@gmail.com> writes:\n\n> When I want to revert a change to a file that is already committed\n> what is the best way?\n>\n> The way I found was:\n>\n> $ git checkout HEAD /path/to/my/file\n> $ git reset HEAD /path/to/my/file\n>\n> Is this the canonical/best way or there other (easier-faster) ways?\n\nIf the issue you are solving is:\n\n  What I committed to path/to/my/file is in good state.  I then\n  edited path/to/my/file but it turns out that I do not like what I\n  did.  I want the version I committed back (perhaps to start over,\n  perhaps to do nothing further).\n\nthen you can checkout the path out of the commit, i.e.\n\n\tgit checkout HEAD path/to/my/file\n\nis the canonical and best way.\n\nBut I am not sure if that is what you are asking with \"want to\nrevert a change to a file that is already commited\".  It can be\nread:\n\n    I started from one state, made changes and have already\n    committed them.  These changes were bad ones that I regret, and\n    I do not want them.\n\nand if so, \"git checkout HEAD path/to/my/file\" will happily grab the\nstate after these bad changes are applied out of the commit.\n"}]}