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

前端 未结 6 1007
误落风尘
误落风尘 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:41

    You may want to use a commit-msg hook that checks whether the word merge occurs in the message for a tentative commit. Something like

    grep -iq merge "$1" || exit 1
    

    after a check for the branch. You may want to make the RE stricter than this. This is only a heuristic, of course, and anyone with write access to the central repo can circumvent this check.

提交回复
热议问题