https://timothya.com/blog/git-stack/
Generic script that works when there are no conflicts
#!/usr/bin/env bash
git checkout --detach master
BOUNDARY="origin/master"
PUSH=""
while read line; do
git cherry-pick "$BOUNDARY".."$line"
git branch --force "$line"
BOUNDARY="origin/$line"
PUSH="$PUSH $line:refs/heads/$line"
done
git push -f origin "$PUSH"
Use when there might be conflicts between cherry-picks to resolve
git checkout --detach main
git cherry-pick origin/main..f1
git branch --force f1
git cherry-pick origin/main..f2
git branch --force f2
git cherry-pick origin/main..f3
git branch --force f3