{"thread":{"id":"33699","subject":"removing a bad commit","startedAt":"2013-05-02T10:15:58Z","lastAt":"2013-05-02T10:33:00Z","messageCount":2,"participants":["shawn wilson","Johan Herland"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"216242","messageId":"CAH_OBifxVOaFMXCthm+r30GNaqrsLRoBE-wvzkeKVxw7R2gGFA@mail.gmail.com","threadId":"33699","inReplyTo":null,"subject":"removing a bad commit","fromName":"shawn wilson","fromEmail":"ag4ve.us@gmail.com","sentAt":"2013-05-02T10:15:58Z","receivedAt":"2013-05-02T10:15:58Z","isPatch":false,"sender":{"key":"ag4ve.us@gmail.com","avatar":null},"body":"I've got a commit that was done about a week ago that I want to remove\n(preferably remove and rewrite history as it's in a branch and it\ndoesn't need to be in this branch until the branch is working) but if\na reverse patch is the only way, i'll go with it.\n"},{"id":"216244","messageId":"CALKQrgdomY_JTzkAaVYsShtLRmc342xEprhkbiiNPitAcWJi+A@mail.gmail.com","threadId":"33699","inReplyTo":"CAH_OBifxVOaFMXCthm+r30GNaqrsLRoBE-wvzkeKVxw7R2gGFA@mail.gmail.com","subject":"Re: removing a bad commit","fromName":"Johan Herland","fromEmail":"johan@herland.net","sentAt":"2013-05-02T10:33:00Z","receivedAt":"2013-05-02T10:33:00Z","isPatch":false,"sender":{"key":"johan@herland.net","avatar":"https://avatars.githubusercontent.com/u/547031?v=4"},"body":"On Thu, May 2, 2013 at 12:15 PM, shawn wilson <ag4ve.us@gmail.com> wrote:\n> I've got a commit that was done about a week ago that I want to remove\n> (preferably remove and rewrite history as it's in a branch and it\n> doesn't need to be in this branch until the branch is working) but if\n> a reverse patch is the only way, i'll go with it.\n\nWhether or not you should rewrite history depends on whether the bad\ncommit has been shared with anybody else. If others have started\nworking on top of your history, they will not enjoy it if you rewrite\nthat history and force them to rebase their work accordingly. In that\ncase, your best bet is a reverse patch: \"git revert $bad_commit_sha1\"\n\nOtherwise, if the bad commit exists nowhere else but your own repo,\nthen you can do an interactive rebase to remove the bad commit: On the\nbranch with the bad commit: \"git rebase -i $bad_commit_sha1^\" (the\ntrailing caret ^ is important). This will launch a text editor listing\nyour last commits starting with your bad commit. Delete the first line\ncontaining your bad commit, and save/exit the editor. Git will now\nreplay all your last commits except for the bad commit. If any of the\nlater commits touch the same stuff as the bad commit did, Git might\nstop the rebase because of conflicts when it replays those patches. In\nthis case, fix the conflicts, add the file, and \"git rebase\n--continue\". Repeat until all commits have been replayed and the\nrebase is finished.\n\nHope this helps,\n\n...Johan\n\n-- \nJohan Herland, <johan@herland.net>\nwww.herland.net\n"}]}