79832595

Date: 2025-11-28 13:32:08
Score: 1.5
Natty:
Report link

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.

Reasons:
  • Has code block (-0.5):
  • User mentioned (1): @andreas-wolf
  • Low reputation (1):
Posted by: Big Pete