0

How to check which branch is the parent branch of the current branch in git, is it possible to check that?

Bennison J
  • 414
  • 1
  • 12

1 Answers1

4

To see the parent directly above your branch run

git show-branch \
| sed "s/].*//" \
| grep "\*" \
| grep -v "$(git rev-parse --abbrev-ref HEAD)" \
| head -n1 \
| sed "s/^.*\[//"

git show-branch works to see the structure as well. Every indent is a branch above. enter image description here

Brandon Kauffman
  • 1,515
  • 1
  • 7
  • 33