Created
December 18, 2020 17:22
-
-
Save thepaul/adc3e98f3b1c3d54e8fcdc2fd597cd38 to your computer and use it in GitHub Desktop.
Get the name of the remote HEAD (the default branch on that remote)
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
#!/bin/bash -e | |
REMOTE=${1:-origin} | |
ref=$(git rev-parse --symbolic-full-name "$REMOTE/HEAD" 2>/dev/null) || { | |
git remote set-head "$REMOTE" -a >/dev/null | |
ref=$(git rev-parse --symbolic-full-name "$REMOTE/HEAD") | |
} | |
echo "${ref#refs/remotes/$REMOTE/}" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment