To use this hook:
- add the
prepare-commit-msgfile at.git/hooks/prepare-commit-msgand edit as needed - make it executable:
chmod +x .git/hooks/prepare-commit-msg - disable fast-forward merges:
git config branch.master.mergeoptions "--no-ff" - that's it!
NOTE: after a failed merge from a forbidden branch, the working tree will still be in a MERGING state. To discard the local working copy state, run:
git reset --merge
If your trying to prevent merging into special branches have a look here https://gist.github.com/mwise/69ec35b646b52d98050d