Created
July 3, 2014 09:58
-
-
Save dkirrane/47c6856d060e19108315 to your computer and use it in GitHub Desktop.
Find the parent branch of the current branch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
current_branch=`git rev-parse --abbrev-ref HEAD` | |
git show-branch -a | grep '*' | grep -v $current_branch | head -n1 | sed 's/.*\[\(.*\)\].*/\1/' | sed 's/[\^~].*//' |
I also have the warning cannot handle more than 25 refs
:(
use 2>nul for git show-branch -a
as in below
current_branch=git rev-parse --abbrev-ref HEAD
git show-branch -a 2>nul | grep '' | grep -v $current_branch | head -n1 | sed 's/.[(.)]./\1/' | sed 's/[^~]].*//'
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
All of the branches got the error like this: cannot handle more than 25 refs