{"id":860,"date":"2014-05-12T05:00:30","date_gmt":"2014-05-12T05:00:30","guid":{"rendered":"http:\/\/tech.avant.net\/q\/?p=860"},"modified":"2019-09-08T07:55:26","modified_gmt":"2019-09-08T07:55:26","slug":"git-obliterate-specific-commits","status":"publish","type":"post","link":"https:\/\/tech.avant.net\/q\/git-obliterate-specific-commits\/","title":{"rendered":"git, obliterate specific commits"},"content":{"rendered":"<p>I would like to obliterate a series of git commits between two points, we&#8217;ll call these the START and END commits.<\/p>\n<p>First, determine the SHA1 for the two commits, we&#8217;ll be forcefully deleting everything in between and preserving the END exactly as it is.<\/p>\n<h2>Detach Head<\/h2>\n<p>Detach head and move to END commit,<\/p>\n<pre class=\"sh_sh\">git checkout SHA1-for-END\n<\/pre>\n<h2>Reset<\/h2>\n<p>Move HEAD to START, but leave the index and working tree as END<\/p>\n<pre class=\"sh_sh\">git reset --soft SHA1-for-START\n<\/pre>\n<h2>Redo END commit<\/h2>\n<p>Redo the END commit re-using the commit message, but on top of START<\/p>\n<pre class=\"sh_sh\">git commit -C SHA1-for-END\n<\/pre>\n<h2>Rebase<\/h2>\n<p>Re-apply everything from the END<\/p>\n<pre class=\"sh_sh\">git rebase --onto HEAD SHA1-for-END master\n<\/pre>\n<h2>Force Push<\/h2>\n<pre class=\"sh_sh\">push -f\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>I would like to obliterate a series of git commits between two points, we&#8217;ll call these the START and END commits. First, determine the SHA1 for the two commits, we&#8217;ll be forcefully deleting everything in between and preserving the END exactly as it is. Detach Head Detach head and move to END commit, git checkout [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":[],"categories":[21,14],"tags":[],"_links":{"self":[{"href":"https:\/\/tech.avant.net\/q\/wp-json\/wp\/v2\/posts\/860"}],"collection":[{"href":"https:\/\/tech.avant.net\/q\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/tech.avant.net\/q\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/tech.avant.net\/q\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/tech.avant.net\/q\/wp-json\/wp\/v2\/comments?post=860"}],"version-history":[{"count":4,"href":"https:\/\/tech.avant.net\/q\/wp-json\/wp\/v2\/posts\/860\/revisions"}],"predecessor-version":[{"id":1042,"href":"https:\/\/tech.avant.net\/q\/wp-json\/wp\/v2\/posts\/860\/revisions\/1042"}],"wp:attachment":[{"href":"https:\/\/tech.avant.net\/q\/wp-json\/wp\/v2\/media?parent=860"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/tech.avant.net\/q\/wp-json\/wp\/v2\/categories?post=860"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/tech.avant.net\/q\/wp-json\/wp\/v2\/tags?post=860"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}