Skip to content

Instantly share code, notes, and snippets.

@dkirrane
Created July 3, 2014 09:58
Show Gist options
  • Save dkirrane/47c6856d060e19108315 to your computer and use it in GitHub Desktop.
Save dkirrane/47c6856d060e19108315 to your computer and use it in GitHub Desktop.
Find the parent branch of the current branch
current_branch=`git rev-parse --abbrev-ref HEAD`
git show-branch -a | grep '*' | grep -v $current_branch | head -n1 | sed 's/.*\[\(.*\)\].*/\1/' | sed 's/[\^~].*//'
@drkvogel
Copy link

drkvogel commented Apr 8, 2021

Just in case anyone else finds this, I wondered how 2>nul worked - it should 2>/dev/null; 2>nul creates a file called nul!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment