Get the parent branch name of your current branch with this:
git rev-parse --abbrev-ref @{-1}
In Windows PowerShell I had to escape the expression.
git rev-parse --abbrev-ref "@{-1}"
The accepted answer by @andreas-wolf is more thorough. I use this where every branch is created with git checkout -b feature, then back into main and merge if required.
From the Git Reference: gitrevisions
The construct @{-<n>} means the <n>th branch/commit checked out before the current one.