Prevent branch switching on git server
PHP中文网
PHP中文网 2017-05-02 09:44:46
0
2
664

Problem scenario: The git branch on the server is master, but sometimes it may be mistakenly switched to another branch (but this is not the focus of the problem). I just want to ask the master if there is any way. The default is the master branch on the server. When using git checkout to switch to other branches, you will be prompted to enter a password.

PHP中文网
PHP中文网

认证0级讲师

reply all(2)
迷茫

I guess you deployed it directly using git, not the situation of building a git server as @xiaoyao9184 said.

The simplest violence is to make .git/HEAD unmodifiable:

 sudo chattr +i .git/HEAD

But no, although the branch cannot be changed, the file will still be checked out.

Or you can try post-checkout hook. After checkout, check whether it is master, and if not, switch back.

If it doesn’t work, just fork a git.

滿天的星座

Don’t think about it, the server is a bare library, there is no concept of switching branches, gitlab can only protect illegal submissions from branches, and the permissions are accurate to the library level

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template