Skip to content

Instantly share code, notes, and snippets.

@milankamilya
Created November 15, 2018 16:12
Show Gist options
  • Save milankamilya/2521ce9cc146e3cfa8b2e14ababadca2 to your computer and use it in GitHub Desktop.
Save milankamilya/2521ce9cc146e3cfa8b2e14ababadca2 to your computer and use it in GitHub Desktop.
Restrict developers from pushing to specific branch or branches
branch="$(git rev-parse --abbrev-ref HEAD)"
#----------------------------------------------------------------
# RESTRICT BRANCHES FROM DIRECT PUSH
#----------------------------------------------------------------
if [ "$branch" = "master" ] || [ "$branch" = "release" ]; then
echo "You can't commit directly to $branch"
exit 1
fi
@provSoniyaPatwa
Copy link

Can we add unit tests in pre-push?

@milankamilya
Copy link
Author

milankamilya commented Dec 1, 2022

@provSoniyaPatwa you can check pre-commit hook. There I have mentioned how to check whether the build is successfully compiling.
Similarly, you can run unit tests before push or commit.

@provSoniyaPatwa
Copy link

@milankamilya thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment