{"id":318,"date":"2017-05-24T13:20:31","date_gmt":"2017-05-24T13:20:31","guid":{"rendered":"http:\/\/www.max-sperling.bplaced.net\/?p=318"},"modified":"2024-02-16T10:43:35","modified_gmt":"2024-02-16T10:43:35","slug":"delete-already-pushed-commits-on-git","status":"publish","type":"post","link":"http:\/\/www.max-sperling.bplaced.net\/?p=318","title":{"rendered":"Delete already pushed commits (Git)"},"content":{"rendered":"<p>The first thing is to checkout the newest commit from the wanted branch.<\/p>\n<pre class=\"brush: plain; gutter: false; title: ; notranslate\" title=\"\">\r\ngit checkout [&lt;branch&gt;]\r\n<\/pre>\n<p>Then you need to get the commit-id you want to go back.<\/p>\n<pre class=\"brush: plain; gutter: false; title: ; notranslate\" title=\"\">\r\ngit log [-&lt;number&gt;]\r\n<\/pre>\n<p>Afterwards you can reset to the choosen commit based on the commit-id.<\/p>\n<pre class=\"brush: plain; gutter: false; title: ; notranslate\" title=\"\">\r\ngit reset --hard &lt;commit-id&gt;\r\n<\/pre>\n<p>At the end you have to sync it with the remote repository.<\/p>\n<pre class=\"brush: plain; gutter: false; title: ; notranslate\" title=\"\">\r\ngit push --force [origin &lt;branch&gt;]\r\n<\/pre>\n<p>Now you have undo all changes until a specific commit.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>The first thing is to checkout the newest commit from the wanted branch. Then you need to get the commit-id<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"inline_featured_image":false},"categories":[24],"tags":[],"_links":{"self":[{"href":"http:\/\/www.max-sperling.bplaced.net\/index.php?rest_route=\/wp\/v2\/posts\/318"}],"collection":[{"href":"http:\/\/www.max-sperling.bplaced.net\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.max-sperling.bplaced.net\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.max-sperling.bplaced.net\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/www.max-sperling.bplaced.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=318"}],"version-history":[{"count":1,"href":"http:\/\/www.max-sperling.bplaced.net\/index.php?rest_route=\/wp\/v2\/posts\/318\/revisions"}],"predecessor-version":[{"id":16822,"href":"http:\/\/www.max-sperling.bplaced.net\/index.php?rest_route=\/wp\/v2\/posts\/318\/revisions\/16822"}],"wp:attachment":[{"href":"http:\/\/www.max-sperling.bplaced.net\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=318"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.max-sperling.bplaced.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=318"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.max-sperling.bplaced.net\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=318"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}