{"id":7891,"date":"2020-07-30T08:02:47","date_gmt":"2020-07-30T08:02:47","guid":{"rendered":"http:\/\/www.max-sperling.bplaced.net\/?p=7891"},"modified":"2024-02-16T10:41:46","modified_gmt":"2024-02-16T10:41:46","slug":"bring-last-x-commits-onto-sub-branch","status":"publish","type":"post","link":"http:\/\/www.max-sperling.bplaced.net\/?p=7891","title":{"rendered":"Create for x last commits a child branch"},"content":{"rendered":"<p>Let&#8217;s asume you have worked on the develop branch and done some commits there. Now you want to create a merge request, which possibly triggers a pipeline (ticket in the right state, app builds correctly and unit tests are running as expected). For that scenario you need a feature branch which sits on to of the newest commit on the develop branch. In the following example I will show you how to get these commit onto a feature branch.<\/p>\n<p>Initial state<\/p>\n<pre>\r\ne73a---6cfa---90ed---c1b0---62d8 [develop]\r\ne73a---6cfa---90ed [origin\/develop]\r\n<\/pre>\n<p>Git commands<\/p>\n<pre>\r\ngit checkout -b feature_branch\r\ngit branch -f develop HEAD~2\r\n<\/pre>\n<p>Resulting state<\/p>\n<pre>\r\n               c1b0---62d8 [feature_branch]\r\n                \/\r\ne73a---6cfa---90ed [develop]\r\ne73a---6cfa---90ed [origin\/develop]\r\n<\/pre>\n<p>Now you can go on with the merge request and afterwards merge your feature branch onto the develop.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Let&#8217;s asume you have worked on the develop branch and done some commits there. Now you want to create a<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","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\/7891"}],"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=7891"}],"version-history":[{"count":1,"href":"http:\/\/www.max-sperling.bplaced.net\/index.php?rest_route=\/wp\/v2\/posts\/7891\/revisions"}],"predecessor-version":[{"id":16814,"href":"http:\/\/www.max-sperling.bplaced.net\/index.php?rest_route=\/wp\/v2\/posts\/7891\/revisions\/16814"}],"wp:attachment":[{"href":"http:\/\/www.max-sperling.bplaced.net\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=7891"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.max-sperling.bplaced.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=7891"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.max-sperling.bplaced.net\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=7891"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}