This might be just a case of me misunderstanding git, but my situation is as follows:
I have a master
branch where I want to have only stable working code. Any addition to this branch must come from a pull-request in bitbucket (could be github or something else, it's just the tool we use). So I want to create a git hook in my local repository to prevent any merging into the master
branch but that also allows me to fetch/pull changes from my remote repository at bitbucket.
I already have git configured to disallow fast-forward merges.
I looked into these solutions that provide something similar, that is to say, a whitelist and a blacklist of branches that can/can't merge into master:
Git hook prevent merging specific branch
https://bl.ocks.org/slattery/5eea0d6ca64687ecba6b
Also this solution prevents me from commiting directly into master, which is also very useful:
Git: Prevent commits in master branch
However I'm not clear if any of these would prevent me from pulling in changes made by pull-requests in bitbucket/github into my local working repository.
Many thanks!
[edit]
As suggested below I had also already setup branch permissions in my bitbucket repo, but that prevents me only from pushing merged master
branches. I want to prevent merging into master
locally instead.