|
|
|
|
|
by xmodem
2105 days ago
|
|
How about #!/bin/sh
BRANCHES_POINTING_TO_HEAD=$(git branch --contains HEAD |wc -l)
CURRENT_BRANCH=$(git branch --show-current)
if [ "$BRANCHES_POINTING_TO_HEAD" -gt 1 ]; then
if [ "$CURRENT_BRANCH" = "master" ]; then
echo "You're committing to master even though other branches exist."
echo "override with git commit --no-verify"
exit 1
fi
fi
You'll need git 2.22 for the --show-current git option.But also I would suggest instead using git checkout -b <new_branch>
to create and switch branches in one command |
|