Created
January 3, 2020 20:56
-
-
Save franzese/eef732ebf9fdd68ceec91c644e00122a to your computer and use it in GitHub Desktop.
Simple script to determine if current git repo is on master (or specified 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
#!/bin/sh | |
# get the current branch name | |
branchName=$(git symbolic-ref --short HEAD) | |
# get the branch name to match from params | |
# if no params, use `master` | |
if [ "$1" != "" ]; then | |
masterBranch="$1" | |
else | |
masterBranch="master" | |
fi | |
# success if they match, error if not | |
if [ "$branchName" = "$masterBranch" ]; then | |
echo SUCCESS: You are on "$branchName" | |
exit 0 | |
else | |
echo ERROR: You are not on "$masterBranch", you are on "$branchName" | |
exit 1 | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment