Skip to content

Instantly share code, notes, and snippets.

@goromlagche
Created December 22, 2023 07:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save goromlagche/8edfaf51aa20993b0bcb0fc032451a1d to your computer and use it in GitHub Desktop.
Save goromlagche/8edfaf51aa20993b0bcb0fc032451a1d to your computer and use it in GitHub Desktop.
#!/bin/bash
current_branch=$(git rev-parse --abbrev-ref HEAD)
remote="$1"
if [ "$current_branch" == "main" ] && [ "$remote" == "origin" ]; then
echo "You can not push to $remote from $current_branch"
exit 1
fi
echo "Pushing to $remote from $current_branch"
exit 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment