Let\'s say I have the following local repository with a commit tree like this:
master --> a \\ \\ develop c --> d
This working fine for me.
git show-branch | grep '*' | grep -v "$(git rev-parse --abbrev-ref HEAD)" | head -n1 | sed 's/.*\[\(.*\)\].*/\1/' | sed 's/[\^~].*//'
Courtesy answers from: @droidbot and @Jistanidiot