{"thread":{"id":"6598","subject":"git-kill: rewrite history removing a commit","startedAt":"2007-01-31T19:55:33Z","lastAt":"2007-02-01T12:41:05Z","messageCount":5,"participants":["Michael S. Tsirkin","Yann Dirson","Junio C Hamano","Catalin Marinas"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"33169","messageId":"20070131195533.GE21097@mellanox.co.il","threadId":"6598","inReplyTo":null,"subject":"git-kill: rewrite history removing a commit","fromName":"Michael S. Tsirkin","fromEmail":"mst@mellanox.co.il","sentAt":"2007-01-31T19:55:33Z","receivedAt":"2007-01-31T19:55:33Z","isPatch":false,"sender":{"key":"mst@kernel.org","avatar":null},"body":"Below is a simple script that rewrites history reverting a single commit.\nThis differs from git-revert in that a commit is completely removed,\nand is especially useful before one has published a series of\ncommits.\n\nDo you find this useful? Comments?\nDrop me a line.\n\n#!/bin/sh\n\ncommit=$1;\n#git-rev-list $commit.. \nrevlist=`git-rev-list $commit.. | tac`\ngit reset --hard $commit\ngit reset --hard HEAD~1\nfor rev in $revlist\ndo\n\tgit-cherry-pick $rev\ndone\n-- \nMST\n"},{"id":"33173","messageId":"20070131202204.GB5362@nan92-1-81-57-214-146.fbx.proxad.net","threadId":"6598","inReplyTo":"20070131195533.GE21097@mellanox.co.il","subject":"Re: git-kill: rewrite history removing a commit","fromName":"Yann Dirson","fromEmail":"ydirson@altern.org","sentAt":"2007-01-31T20:22:04Z","receivedAt":"2007-01-31T20:22:04Z","isPatch":false,"sender":{"key":"ydirson@altern.org","avatar":"https://avatars.githubusercontent.com/u/1190950?v=4"},"body":"On Wed, Jan 31, 2007 at 09:55:33PM +0200, Michael S. Tsirkin wrote:\n> Below is a simple script that rewrites history reverting a single commit.\n> This differs from git-revert in that a commit is completely removed,\n> and is especially useful before one has published a series of\n> commits.\n> \n> Do you find this useful? Comments?\n\nThat may be well when no patch depends on the one you kill.  In that\ncase, it surely requires some work to handfix things.\n\nI'd suggest to use stgit to prepare commits before publication.  Even\nif you don't feel the need for it in everyday life, you can have a\none-shot use for this particular problem, by turning your latest\ncommits into an stgit stack, use stgit facilities to handle posible\nconflicts, and turn them into commits again:\n\nThe nominal case goes:\n\n  stg init\n  stg uncommit -n <ncommits>\n  stg float <patch-to-kill>\n  stg delete <patch-to-kill>\n\nAnd if there is any conflict, you can still solve them, decide to\nchange your plans, get diffs from gitk, etc.\n\nBest regards,\n-- \nYann.\n"},{"id":"33174","messageId":"7v7iv3uelv.fsf@assigned-by-dhcp.cox.net","threadId":"6598","inReplyTo":"20070131195533.GE21097@mellanox.co.il","subject":"Re: git-kill: rewrite history removing a commit","fromName":"Junio C Hamano","fromEmail":"junkio@cox.net","sentAt":"2007-01-31T20:26:52Z","receivedAt":"2007-01-31T20:26:52Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"\"Michael S. Tsirkin\" <mst@mellanox.co.il> writes:\n\n> Below is a simple script that rewrites history reverting a single commit.\n> This differs from git-revert in that a commit is completely removed,\n> and is especially useful before one has published a series of\n> commits.\n>\n> Do you find this useful? Comments?\n> Drop me a line.\n\n\"Do you find this useful\" is a loaded question.\n\nI do it all the time with git-rebase, so the need to remove a\nbotched commit from the history and rebuild the remainder is\ncertainly there, meaning \"what your patch does IS useful\".\n\nI do it all the time with git-rebase, so I personally do not\nneed a new tool to do this, meaning \"your patch is not useful to\nme\".\n\nWhen I find master~8 and master~9 to be undesirable, I would do:\n\n\t$ git rebase --onto master~10 master~8\n\nwhich rebuilds master~7 and onward on top of master~10, thereby\ndropping two commits.\n"},{"id":"33176","messageId":"20070131205402.GH21097@mellanox.co.il","threadId":"6598","inReplyTo":"7v7iv3uelv.fsf@assigned-by-dhcp.cox.net","subject":"Re: git-kill: rewrite history removing a commit","fromName":"Michael S. Tsirkin","fromEmail":"mst@mellanox.co.il","sentAt":"2007-01-31T20:54:02Z","receivedAt":"2007-01-31T20:54:02Z","isPatch":false,"sender":{"key":"mst@kernel.org","avatar":null},"body":"> When I find master~8 and master~9 to be undesirable, I would do:\n> \n> \t$ git rebase --onto master~10 master~8\n> \n> which rebuilds master~7 and onward on top of master~10, thereby\n> dropping two commits.\n\nThat's good to know.\nSo it turns out I can just rewrite mine as a one-liner:\ngit-rebase --onto $1~1 $1\n\nThanks,\n\n-- \nMST\n"},{"id":"33228","messageId":"tnxzm7yhwym.fsf@arm.com","threadId":"6598","inReplyTo":"20070131202204.GB5362@nan92-1-81-57-214-146.fbx.proxad.net","subject":"Re: git-kill: rewrite history removing a commit","fromName":"Catalin Marinas","fromEmail":"catalin.marinas@arm.com","sentAt":"2007-02-01T12:41:05Z","receivedAt":"2007-02-01T12:41:05Z","isPatch":false,"sender":{"key":"catalin.marinas@arm.com","avatar":null},"body":"Yann Dirson <ydirson@altern.org> wrote:\n> I'd suggest to use stgit to prepare commits before publication.  Even\n> if you don't feel the need for it in everyday life, you can have a\n> one-shot use for this particular problem, by turning your latest\n> commits into an stgit stack, use stgit facilities to handle posible\n> conflicts, and turn them into commits again:\n>\n> The nominal case goes:\n>\n>   stg init\n>   stg uncommit -n <ncommits>\n>   stg float <patch-to-kill>\n>   stg delete <patch-to-kill>\n\nor \"stg pop <patch-to-kill>\" instead of 'float'. Recently, I changed the\n'pop' command to accept individual patches and patch ranges (for\nsymmetry with 'push').\n\n-- \nCatalin\n"}]}