Prevent accidental push's to master
Closed this issue · 1 comments
hpjaj commented
Background
Per human error, someone might mistakenly push changes directly to master
.
Definition of Done
- Research and implement a protection that prohibit's user's from accidentally pushing directly to
master
kfrz commented
Branch protection rules will:
- protect merges without green status/reviews
- disallow
git push -f
- prevent deletion of branch
If we want to protect pushing from local to remote we probably want a hook.
Something like this in .git/hooks/pre-commit
will prevent committing to master
altogether.
#!/bin/sh
branch="$(git rev-parse --abbrev-ref HEAD)"
if [ "$branch" = "master" ]; then
echo "Please do not commit directly to master"
exit 1
fi
Downside with the hook is it's not something we can just commit to the project repo, each dev would have to have it added locally, unless we used a symlink strategy or shared-git-hooks