Create for x last commits a child branch

Let’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.

Initial state

e73a---6cfa---90ed---c1b0---62d8 [develop]
e73a---6cfa---90ed [origin/develop]

Git commands

git checkout -b feature_branch
git branch -f develop HEAD~2

Resulting state

               c1b0---62d8 [feature_branch]
                /
e73a---6cfa---90ed [develop]
e73a---6cfa---90ed [origin/develop]

Now you can go on with the merge request and afterwards merge your feature branch onto the develop.