Last active
June 22, 2025 23:11
-
-
Save Nunocky/eeb9129adf8c6e275fe037f2dc479d1d to your computer and use it in GitHub Desktop.
main, developへの merge, rebaseの禁止
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 | |
protected_branches="main develop" | |
current_branch=$(git symbolic-ref --short HEAD) | |
for branch in $protected_branches; do | |
if [ "$current_branch" = "$branch" ]; then | |
echo "❌ ERROR: You cannot commit directly to '$branch' branch!" | |
exit 1 | |
fi | |
done | |
exit 0 |
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/bash | |
protected_branches="main develop" | |
branch=$(git rev-parse --abbrev-ref HEAD) | |
# Check if current branch is in protected_branches | |
for protected_branch in $protected_branches; do | |
if [ "$branch" = "$protected_branch" ]; then | |
echo "❌ ERROR: You cannot perform a merge on '$branch'!" | |
exit 1 | |
fi | |
done |
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 | |
protected_branches="main develop" | |
while read local_ref local_sha remote_ref remote_sha | |
do | |
for branch in $protected_branches; do | |
if echo "$remote_ref" | grep -Eq "refs/heads/$branch$"; then | |
echo "❌ ERROR: Pushing to '$branch' branch is not allowed!" | |
exit 1 | |
fi | |
done | |
done | |
exit 0 |
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 | |
protected_branches="main develop" | |
current_branch=$(git symbolic-ref --short HEAD) | |
for branch in $protected_branches; do | |
if [ "$current_branch" = "$branch" ]; then | |
echo "❌ ERROR: Rebase is not allowed on '$branch' branch!" | |
exit 1 | |
fi | |
done | |
exit 0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment