Prevent direct commits on master branch in git repository and accept merges only?

前端 未结 6 1011
误落风尘
误落风尘 2021-02-05 02:10

My git repository has two branches, \'master\' and \'dev\'.

Code committed to \'dev\' goes through an automated build process before it is tested. Code that passes this

6条回答
  •  粉色の甜心
    2021-02-05 02:32

    npm install -D husky
    
    npm i git-branch-is
    

    configure it through package.json

        "husky": {
          "hooks": {
            "pre-commit": "git-branch-is -r \"^((?!master).)*$\""
        }
      }
    

提交回复
热议问题