{"thread":{"id":"13814","subject":"Problems reverting (includes reverting a merge)","startedAt":"2008-06-05T17:45:55Z","lastAt":"2008-06-09T09:00:19Z","messageCount":3,"participants":["jenny w","Andreas Ericsson","Alex Bennee"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"78787","messageId":"b1d95faa0806051045t67ea0f46r55cdaeb794dc2f5c@mail.gmail.com","threadId":"13814","inReplyTo":null,"subject":"Problems reverting (includes reverting a merge)","fromName":"jenny w","fromEmail":"veganjenny@gmail.com","sentAt":"2008-06-05T17:45:55Z","receivedAt":"2008-06-05T17:45:55Z","isPatch":false,"sender":{"key":"veganjenny@gmail.com","avatar":null},"body":"Someone made a few commits that I'm trying to revert. There are three\ncommits in a row, the middle of which is a merge. There are presently\nno commits following the ones that we want to revert.\n\nI tried git revert on the latest commit and that worked fine.\n\nThe second latest commit was a merge, so I had to use the -m switch.\nI'm not exactly sure what the parent-number refers to, so I created a\nseparate branch to try things out. Since it expects I a number, I\nstarted from 1. That was kind of a disaster, so I deleted my branch\nand made another off of master, and then tried doing the same command\nwith -m 2. This worked fine.  However ...\n\nI then tried to revert the next commit. This said there's a conflict.\nSince there are no other commits after the ones I'm trying to revert,\nthis makes me think I'm doing something wrong ... shouldn't it just be\nable to roll back?\n\nWhat I'd really like to do is just zap the last 3 commits ... is there\nanother way to just make things the way they were before these patches\nwere applied?\n\nAny help with any of the above would be greatly appreciated!\n"},{"id":"79212","messageId":"484CE438.6040703@op5.se","threadId":"13814","inReplyTo":"b1d95faa0806051045t67ea0f46r55cdaeb794dc2f5c@mail.gmail.com","subject":"Re: Problems reverting (includes reverting a merge)","fromName":"Andreas Ericsson","fromEmail":"ae@op5.se","sentAt":"2008-06-09T08:05:12Z","receivedAt":"2008-06-09T08:05:12Z","isPatch":false,"sender":{"key":"ae@op5.se","avatar":"https://gravatar.com/avatar/426e89595c75a8f5252dd0c989e5fabe5bcac616e68557427ad9aef6b0ca342a?d=mp&s=160"},"body":"jenny w wrote:\n> Someone made a few commits that I'm trying to revert. There are three\n> commits in a row, the middle of which is a merge. There are presently\n> no commits following the ones that we want to revert.\n> \n> I tried git revert on the latest commit and that worked fine.\n> \n> The second latest commit was a merge, so I had to use the -m switch.\n> I'm not exactly sure what the parent-number refers to, so I created a\n> separate branch to try things out. Since it expects I a number, I\n> started from 1. That was kind of a disaster, so I deleted my branch\n> and made another off of master, and then tried doing the same command\n> with -m 2. This worked fine.  However ...\n> \n> I then tried to revert the next commit. This said there's a conflict.\n> Since there are no other commits after the ones I'm trying to revert,\n> this makes me think I'm doing something wrong ... shouldn't it just be\n> able to roll back?\n> \n> What I'd really like to do is just zap the last 3 commits ... is there\n> another way to just make things the way they were before these patches\n> were applied?\n> \n\ngit diff HEAD~3 | git apply -R && git commit <relevant files>\n\nAlthough that will revert all 3 of them in one go, but perhaps that's\nok? Oh, and it won't work unless the merge-parent you want to revert\nis the \"first\" parent (a straight line to the left when viewed in gitk\nor qgit).\n\nIf you haven't published the commits anywhere yet, you can do\n\n\tgit reset --hard HEAD~3\n\nNote that this will clobber your worktree though, so use with caution.\n\n-- \nAndreas Ericsson                   andreas.ericsson@op5.se\nOP5 AB                             www.op5.se\nTel: +46 8-230225                  Fax: +46 8-230231\n"},{"id":"79215","messageId":"1213002019.26678.2.camel@pitcairn.cambridgebroadband.com","threadId":"13814","inReplyTo":"b1d95faa0806051045t67ea0f46r55cdaeb794dc2f5c@mail.gmail.com","subject":"Re: Problems reverting (includes reverting a merge)","fromName":"Alex Bennee","fromEmail":"kernel-hacker@bennee.com","sentAt":"2008-06-09T09:00:19Z","receivedAt":"2008-06-09T09:00:19Z","isPatch":false,"sender":{"key":"kernel-hacker@bennee.com","avatar":null},"body":"On Thu, 2008-06-05 at 10:45 -0700, jenny w wrote:\n\n> What I'd really like to do is just zap the last 3 commits ... is there\n> another way to just make things the way they were before these patches\n> were applied?\n\nWouldn't git-reset --hard HEAD^^^ do what you want. It will rewind your\ntree to 3 commits bellow the current head, the --hard ensure your\nworking tree is cleared out as well.\n\n> \n> Any help with any of the above would be greatly appreciated!\n> --\n> To unsubscribe from this list: send the line \"unsubscribe git\" in\n> the body of a message to majordomo@vger.kernel.org\n> More majordomo info at  http://vger.kernel.org/majordomo-info.html\n-- \nAlex, homepage: http://www.bennee.com/~alex/\nEnvy is a pain of mind that successful men cause their neighbors. --\nOnasander\n"}]}