GitButler handles all of this pretty automatically, if you don't want to deal with the Git gymnastics needed here.
https://blog.gitbutler.com/stacked-branches-with-gitbutler