{"thread":{"id":"24329","subject":"Question about git revert","startedAt":"2010-07-08T01:50:19Z","lastAt":"2010-07-08T04:51:05Z","messageCount":3,"participants":["Hal Eisen","Christian Couder","Elijah Newren"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"145076","messageId":"20100708015019.GP10042@volcano.builtonlinux.com","threadId":"24329","inReplyTo":null,"subject":"Question about git revert","fromName":"Hal Eisen","fromEmail":"eisen@dunhackin.org","sentAt":"2010-07-08T01:50:19Z","receivedAt":"2010-07-08T01:50:19Z","isPatch":false,"sender":{"key":"eisen@dunhackin.org","avatar":null},"body":"I did a search of the archives for this mailing list, and couldn't\nfind anything applicable.\n\nI am having the same problem as Joshua Cheek.  He asked this question\non StackOverflow about a month ago.\n\nhttp://stackoverflow.com/questions/2938301/git-remove-specific-commit\n\nThere are no merges involved.  I would be perfectly happy having\nanother commit in my history which documents the reverting of a prior\ncommit.\n\nThe problem seems to stem from git-revert not properly calculating the\n\"cleanness\" of the prior commit, and incorrectly thinking that later\ncommits depend on the to-be-reverted commit.\n\nI have seen other web sites which suggest using git to manually\ngenerate a diff, and then applying it as a reverse patch, but that\nseems like a kludge.\n\nWhat is the best solution for this use case?\n\nThanks,\nHal\n"},{"id":"145080","messageId":"201007080505.02633.chriscool@tuxfamily.org","threadId":"24329","inReplyTo":"20100708015019.GP10042@volcano.builtonlinux.com","subject":"Re: Question about git revert","fromName":"Christian Couder","fromEmail":"chriscool@tuxfamily.org","sentAt":"2010-07-08T03:05:02Z","receivedAt":"2010-07-08T03:05:02Z","isPatch":false,"sender":{"key":"christian.couder@gmail.com","avatar":"https://avatars.githubusercontent.com/u/208954?v=4"},"body":"On Thursday 08 July 2010 03:50:19 Hal Eisen wrote:\n> I did a search of the archives for this mailing list, and couldn't\n> find anything applicable.\n> \n> I am having the same problem as Joshua Cheek.  He asked this question\n> on StackOverflow about a month ago.\n> \n> http://stackoverflow.com/questions/2938301/git-remove-specific-commit\n> \n> There are no merges involved.  I would be perfectly happy having\n> another commit in my history which documents the reverting of a prior\n> commit.\n> \n> The problem seems to stem from git-revert not properly calculating the\n> \"cleanness\" of the prior commit, and incorrectly thinking that later\n> commits depend on the to-be-reverted commit.\n\nYou may want to try \"git revert\" with the new --strategy option,\nfor example \"git revert --strategy resolve <commit>\". This option is not in a \nreleased version yet, so you should use one of the last git version from the \nmaster branch, for example v1.7.2-rc2.\n\n> I have seen other web sites which suggest using git to manually\n> generate a diff, and then applying it as a reverse patch, but that\n> seems like a kludge.\n> \n> What is the best solution for this use case?\n\nIt depends on how well the revert algorithms work in the case you are \ninterested in. If one strategy works quite well, then manually fixing the few \nremaining problems, if any, in the result is probably the best solution. \n\nRegards,\nChristian.\n"},{"id":"145086","messageId":"AANLkTimcNThv2qJBcJKpj5qzoFzZtLHfVq_TwyqTIKAo@mail.gmail.com","threadId":"24329","inReplyTo":"20100708015019.GP10042@volcano.builtonlinux.com","subject":"Re: Question about git revert","fromName":"Elijah Newren","fromEmail":"newren@gmail.com","sentAt":"2010-07-08T04:51:05Z","receivedAt":"2010-07-08T04:51:05Z","isPatch":false,"sender":{"key":"newren@gmail.com","avatar":"https://avatars.githubusercontent.com/u/5455730?v=4"},"body":"Hi,\n\nOn Wed, Jul 7, 2010 at 7:50 PM, Hal Eisen <eisen@dunhackin.org> wrote:\n> I did a search of the archives for this mailing list, and couldn't\n> find anything applicable.\n>\n> I am having the same problem as Joshua Cheek.  He asked this question\n> on StackOverflow about a month ago.\n>\n> http://stackoverflow.com/questions/2938301/git-remove-specific-commit\n>\n> There are no merges involved.  I would be perfectly happy having\n> another commit in my history which documents the reverting of a prior\n> commit.\n>\n> The problem seems to stem from git-revert not properly calculating the\n> \"cleanness\" of the prior commit, and incorrectly thinking that later\n> commits depend on the to-be-reverted commit.\n\nReverts will only be clean if you're undoing changes on lines that\nhaven't been touched in subsequent commits AND the 3 lines on both\nsides of such changes have not been modified either.  (The 3 lines of\ncontext means that in your example, later commits _do_ depend on the\nto-be-reverted commit).  In your example, you're dealing with a file\nwith only three lines, one line added per commit.  Thus, in that\nexample, you can't revert any of the commits cleanly except the last.\n\n> I have seen other web sites which suggest using git to manually\n> generate a diff, and then applying it as a reverse patch, but that\n> seems like a kludge.\n\nThis solution would have the exact same problem (unless you created a\npatch with 0 lines of context).\n\n> What is the best solution for this use case?\n\nManually fix the conflict.  Or see Christian's email about using\nspecial strategies, if you can find or write one for this special case\nthat doesn't depend on context lines (a strategy that is usually not\ndesirable for source code).\n\n\nHope that helps,\nElijah\n"}]}