Thanks for a clear example repo, it made it trivial to answer this question.
NB All the following command assume that everything is checked in and no files are modified at the start.
Step 0
Start using gitk --all
as your every-day version history visualization tool from today and the rest of your life. Neither vscode nor any other IDEs have anything that is remotely close to as useful as gitk.
Step 1
So you you have this

but would rather have this?

No problem.
Steps for the initial code setup:
git clone https://github.com/KijeviGombooc/merge_test
cd merge_test
git branch b1 origin/b1
git tag old-not-really-merge 3457a643 # Tagging just for convenience
git branch new_master1 old-not-really-merge^ # Branch from the parent of the tag
git branch new_master2 master
which gives

(no code changes yet).
Step 2
Create a real merge commit.
git switch new_master1
git merge b1 # This gives a merge conflict ...
git resolve-conflict-using-kdiff3 # ... which is easy to resolve with good tools.
git commit # Finishing the merge.
Using KDiff3 the conflict was resolved the same way as the existing commit Merge branch 'b1':

which gives the following result:

Step 3
Now the only remaining part is to include the changes made after old-not-really-merge:
git rebase --onto new_master1 old-not-really-merge new_master2
git branch --delete new_master1
At this point new_master2
is the result you asked for. It is a good idea to verify that the new branch is not fundamentally different:
git diff master new_master2
diff --git a/test.txt b/test.txt
index 8d069ed..d5340c7 100644
--- a/test.txt
+++ b/test.txt
@@ -1,2 +1,2 @@
this is a file
-Line from b1
+Line from b1
\ No newline at end of file
In this case there was a difference in line ending on the last line because you and I resolved the merge conflict slightly differently. You have to judge if changes like that are ok or not.

Step 4
After you have verified that new_master2
is what you wanted you can reset the original master
branch to the new branch:
git switch master
git reset --hard new_master2
git branch -d new_master2
git tag -d old-not-really-merge
git push --force origin master
which then should give the same result as the second screenshot1.
At the end now I notice that the merge commit references the branch name new_branch1
so a better approach would have been to start with renaming master
to master.old
and then use the name master
instead of new_branch1
. I'm not redoing commands and screenshots to fix that.
1 I obviously did not push back to your origin
repo, so the screenshot was taken from a "second level" local clone made with git clone merge_test merge_test2
which then has my first merge_test repo as its origin
.