Last active
November 8, 2020 20:40
-
-
Save taiki-e/5817b637930e65aacef2c6b73a3d3865 to your computer and use it in GitHub Desktop.
Getting the default branch of a remote repository
This file contains hidden or 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
# Gets the default branch of a remote repository. | |
# | |
# Example: git fetch --prune upstream && && git merge "upstream/$(default_branch upstream)" | |
function default_branch() { | |
git remote show "${1:-origin}" | grep 'HEAD branch' | sed 's/ *HEAD branch: //' | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment