Git: How to protect a development branch / wizard in git-flow (from beginners) through access control?

In previous days I read the https://www.atlassian.com/git/tutorials/comparing-workflows/forking-workflow , which I have a question for.

If the project uses Feature or Gitflow Branch Workflows: is there a parameter that the user clicks on the function branch as the branch of the tracking function to the source, issues a pull request and ONLY the project developer can combine the tracking function branch into a wizard (Feature Branch workflow) or develop (Gitlow branch workflow)?

In other words: is it possible to assign branches to users, so there is no need for a Forking Workflow if you do not want to complicate the situation excessively, but still have a guaranteed review of the code that provides the master / development branch from beginners?

+6
source share
1 answer

Remote git services, such as github, bitbucket, gitlab, vsts, etc., have the ability to "protect" branches to prevent direct clicking on them or deleting a branch. If you want to simulate something like this on your local computer, you can use git hooks: https://git-scm.com/book/en/v2/Customizing-Git-Git-Hooks

Example for preventing commits: https://gist.github.com/aaronhoffman/ffbfd36928f9336be2436cffe39feaec

pre-commit file:

#!/bin/sh # prevent commit to local master branch branch=`git symbolic-ref HEAD` if [ "$branch" = "refs/heads/master" ]; then echo "pre-commit hook: Can not commit to the local master branch." exit 1 fi exit 0 

preliminary file:

 #!/bin/sh # Prevent push to remote master branch while read local_ref local_sha remote_ref remote_sha do if [ "$remote_ref" = "refs/heads/master" ]; then echo "pre-push hook: Can not push to remote master branch." exit 1 fi done exit 0 
0
source

All Articles