Last active
August 18, 2023 18:45
-
-
Save drbrain/1e998cbcc328e8d6193a3bf9382dffb5 to your computer and use it in GitHub Desktop.
Switch to the default branch of this git 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
#!/bin/sh | |
# git-default | |
# | |
# Switch to the repository's default branch | |
default=`git symbolic-ref refs/remotes/origin/HEAD | cut -d '/' -f 4` | |
current=`git branch --show-current` | |
if [ "x${default}" = "x${current}" ]; then | |
exit 0 | |
fi | |
git switch ${default} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment